Back to Collection Items
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loHttp = createobject("CkHttp")
loReq = createobject("CkHttpRequest")
loJsonParam1 = createobject("CkJsonObject")
loReq.AddParam("username",loJsonParam1.Emit())
loJsonParam2 = createobject("CkJsonObject")
loReq.AddParam("password",loJsonParam2.Emit())
loReq.AddParam("grant_type","password")
loJsonParam4 = createobject("CkJsonObject")
loReq.AddParam("client_id",loJsonParam4.Emit())
loJsonParam5 = createobject("CkJsonObject")
loReq.AddParam("client_secret",loJsonParam5.Emit())
loReq.AddParam("scope","lp")
loResp = loHttp.PostUrlEncoded("https://domain.com/",loReq)
if (loHttp.LastMethodSuccess = .F.) then
? loHttp.LastErrorText
release loHttp
release loReq
release loJsonParam1
release loJsonParam2
release loJsonParam4
release loJsonParam5
return
endif
? str(loResp.StatusCode)
? loResp.BodyStr
release loResp
release loHttp
release loReq
release loJsonParam1
release loJsonParam2
release loJsonParam4
release loJsonParam5
Curl Command
curl -X POST
-H "Content-Type: application/x-www-form-urlencoded"
--data-urlencode 'username={{encompass_username}}@encompass:{{encompass_instance_id}}'
--data-urlencode 'password={{encompass_password}}'
--data-urlencode 'grant_type=password'
--data-urlencode 'client_id={{lender_client_id}}'
--data-urlencode 'client_secret={{lender_client_secret}}'
--data-urlencode 'scope=lp'
https://domain.com/
Postman Collection Item JSON
{
"name": "[Lender] Create Lender Authentication Token",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"// Extract Lender oAuth token from response body",
"var jsonData = JSON.parse(responseBody);",
"var lenderToken = jsonData.access_token;",
"",
"// Set to an environment variable",
"postman.setEnvironmentVariable(\"lender_token\", lenderToken);"
]
}
}
],
"_postman_id": "dcaf78e5-430f-47e0-9d98-ef4313352ace",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/x-www-form-urlencoded",
"type": "text"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "username",
"value": "{{encompass_username}}@encompass:{{encompass_instance_id}}",
"type": "text"
},
{
"key": "password",
"value": "{{encompass_password}}",
"type": "text"
},
{
"key": "grant_type",
"value": "password",
"type": "text"
},
{
"key": "client_id",
"value": "{{lender_client_id}}",
"type": "text"
},
{
"key": "client_secret",
"value": "{{lender_client_secret}}",
"type": "text"
},
{
"key": "scope",
"value": "lp",
"type": "text"
}
]
},
"url": "{{api_host}}/oauth2/v1/token"
},
"response": [
]
}