Klaas API
Generate Access Token
1 min
{ "name" "token", "method" "post", "url" "https //api sandbox klavi ai/token", "description" "generate access token", "tab" "examples", "examples" { "languages" \[ { "id" "jxze0ye qs75vjob ib t", "language" "curl", "code" "curl location 'https //api sandbox klavi ai/token' \\\\\n header 'accept application/json' \\\\\n header 'content type application/x www form urlencoded' \\\\\n data '{\n \\"grant type\\" \\"string\\",\n \\"scope\\" \\"string\\",\n \\"client id\\" \\"string\\",\n \\"client secret\\" \\"string\\"\n}'", "customlabel" "" }, { "id" "4 t49ypatjdfc1avrsc6z", "language" "nodejs", "code" "var request = require('request');\nvar options = {\n 'method' 'post',\n 'url' 'https //api sandbox klavi ai/token',\n 'headers' {\n 'accept' 'application/json',\n 'content type' 'application/x www form urlencoded'\n },\n body json stringify({\n \\"grant type\\" \\"string\\",\n \\"scope\\" \\"string\\",\n \\"client id\\" \\"string\\",\n \\"client secret\\" \\"string\\"\n })\n\n};\nrequest(options, function (error, response) {\n if (error) throw new error(error);\n console log(response body);\n});\n", "customlabel" "" }, { "id" "tp 32ry5b15 x tjn2swz", "language" "javascript", "code" "var myheaders = new headers();\nmyheaders append(\\"accept\\", \\"application/json\\");\nmyheaders append(\\"content type\\", \\"application/x www form urlencoded\\");\n\nvar raw = json stringify({\n \\"grant type\\" \\"string\\",\n \\"scope\\" \\"string\\",\n \\"client id\\" \\"string\\",\n \\"client secret\\" \\"string\\"\n});\n\nvar requestoptions = {\n method 'post',\n headers myheaders,\n body raw,\n redirect 'follow'\n};\n\nfetch(\\"https //api sandbox klavi ai/token\\", requestoptions)\n then(response => response text())\n then(result => console log(result))\n catch(error => console log('error', error));", "customlabel" "" }, { "id" "bkgo0l3da7rxa0lcd0nvr", "language" "python", "code" "import requests\nimport json\n\nurl = \\"https //api sandbox klavi ai/token\\"\n\npayload = json dumps({\n \\"grant type\\" \\"string\\",\n \\"scope\\" \\"string\\",\n \\"client id\\" \\"string\\",\n \\"client secret\\" \\"string\\"\n})\nheaders = {\n 'accept' 'application/json',\n 'content type' 'application/x www form urlencoded'\n}\n\nresponse = requests request(\\"post\\", url, headers=headers, data=payload)\n\nprint(response text)\n", "customlabel" "" }, { "id" "trs0uddlaoqx2eyqqnwuw", "language" "ruby", "code" "require \\"uri\\"\nrequire \\"json\\"\nrequire \\"net/http\"\n\nurl = uri(\\"https //api sandbox klavi ai/token\\")\n\nhttps = net http new(url host, url port)\nhttps use ssl = true\n\nrequest = net http post new(url)\nrequest\[\\"accept\\"] = \\"application/json\\"\nrequest\[\\"content type\\"] = \\"application/x www form urlencoded\\"\nrequest body = json dump({\n \\"grant type\\" \\"string\\",\n \\"scope\\" \\"string\\",\n \\"client id\\" \\"string\\",\n \\"client secret\\" \\"string\\"\n})\n\nresponse = https request(request)\nputs response read body\n", "customlabel" "" } ], "selectedlanguageid" "jxze0ye qs75vjob ib t" }, "results" { "languages" \[ { "id" "8glitm36uwbwxhnv0w2xu", "language" "200", "customlabel" "", "code" "{\n \\"access token\\" \\"eyjhbgcioijsuzi1niisinr5ccigoiaislduiiwia2lkiia6icjyqnhoz1nwt0rqzgljnufaaznkclppnfnbzgn2sgoybgn2a05mqjftdznrin0 eyjlehaioje3nte1otk4nzksimlhdci6mtc1mtu5otu3oswianrpijoimjq4mwfiodytmgnmnc00mzgzlwiyowqtnwrhmgy3ntyzzty1iiwiaxnzijoiahr0chm6ly9tdgxzlwfwas1zb3blbi5rbgf2as5has9yzwfsbxmvs2xhdmlpqxv0acisinn1yii6ijnlywmynmjhltlin2qtngyzmi05otnlltnjy2jim2nhzjyxncisinr5cci6ikjlyxjlciisimf6cci6iktsyxzpvgvzdcisimfjcii6invybjpicmfzaww6b3blbmjhbmtpbmc6bg9hmiisinnjb3blijoia2xhyxmilcjjbgllbnrib3n0ijoimtaumi4xmjgumje3iiwiy2xpzw50qwrkcmvzcyi6ijewljiumti4ljixnyisimnsawvudf9pzci6iktsyxzpvgvzdcj9 gyabzeped2exchi jsdv8uvwomfpwnn1tp80ct5dnp6dmh5sjfw3x394g0pld8iry75qfbvvz527bumul9dhqs6z32n3a ex6smyt9eom vtt8cynrlwpg rjwxqps05hfchkkh c48h8pou8evl5d2f0efnpgn6lvyz9mdekpaukinm6anxn4uclff7wrqvsoszaoovq5eb j7lxmndazn7ktzvweuwk8b5mr5pzf ozets5vh 9xlazw gk5vmlxr 7qujr2iiihqbkogu8bfc0aa8qm1v75fa fdbpork6sf3ibgk ubn4bfpvgwtfofygvwbaiob9wnugsqddq\\",\n \\"expires in\\" 300,\n \\"token type\\" \\"bearer\\",\n \\"scope\\" \\"klaas\\"\n}" } ], "selectedlanguageid" "8glitm36uwbwxhnv0w2xu" }, "request" { "pathparameters" \[], "queryparameters" \[], "headerparameters" \[ { "name" "content type", "kind" "required", "type" "string", "description" "currently only support 'application/x www form urlencoded'", "" "currently only support 'application/x www form urlencoded'" } ], "bodydataparameters" \[ { "name" "grant type", "kind" "required", "type" "string", "description" "currently only support 'client credentials'", "" "grant type" }, { "name" "scope", "kind" "required", "type" "string", "description" "currently only support 'klaas'", "" "currently only support 'klaas'" }, { "name" "client id", "kind" "required", "type" "string", "description" "client id", "" "client id" }, { "name" "client secret", "kind" "required", "type" "string", "description" "client secret", "" "client secret" } ], "formdataparameters" \[] }, "currentnewparameter" { "label" "header parameter", "value" "headerparameters" }, "hastryitout" false, "response" \[ { "name" "access token", "kind" "optional", "type" "string", "description" "access token" }, { "name" "expires in", "kind" "optional", "type" "number", "description" "token validity period\ndefault 300 seconds", "children" \[] }, { "name" "token type", "kind" "optional", "type" "string", "description" "token type\ndefault value bearer", "children" \[] }, { "name" "scope", "kind" "optional", "type" "string", "description" "default value klaas", "children" \[] } ] }