Back to Collection Items
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Http")
set http = CreateObject("Chilkat.Http")
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.HttpRequest")
set req = CreateObject("Chilkat.HttpRequest")
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set jsonParam1 = CreateObject("Chilkat.JsonObject")
req.AddParam "username",jsonParam1.Emit()
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set jsonParam2 = CreateObject("Chilkat.JsonObject")
req.AddParam "password",jsonParam2.Emit()
req.AddParam "grant_type","password"
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set jsonParam4 = CreateObject("Chilkat.JsonObject")
req.AddParam "client_id",jsonParam4.Emit()
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set jsonParam5 = CreateObject("Chilkat.JsonObject")
req.AddParam "client_secret",jsonParam5.Emit()
req.AddParam "scope","lp"
' resp is a Chilkat.HttpResponse
Set resp = http.PostUrlEncoded("https://domain.com/",req)
If (http.LastMethodSuccess = 0) Then
outFile.WriteLine(http.LastErrorText)
WScript.Quit
End If
outFile.WriteLine(resp.StatusCode)
outFile.WriteLine(resp.BodyStr)
outFile.Close
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": [
]
}