Classic ASP / Salesforce Platform APIs / Username Password Login - Authorize
Back to Collection Items
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
set http = Server.CreateObject("Chilkat.Http")
set req = Server.CreateObject("Chilkat.HttpRequest")
req.AddParam "response_type","code_credentials"
set jsonParam2 = Server.CreateObject("Chilkat.JsonObject")
req.AddParam "client_id",jsonParam2.Emit()
set jsonParam3 = Server.CreateObject("Chilkat.JsonObject")
req.AddParam "redirect_uri",jsonParam3.Emit()
req.AddHeader "Auth-Request-Type","Named-User"
req.AddHeader "Authorization","Basic <username:password>"
set resp = Server.CreateObject("Chilkat.HttpResponse")
req.HttpVerb = "POST"
req.ContentType = "application/x-www-form-urlencoded"
success = http.HttpReq("https://login.salesforce.com{{site}}/services/oauth2/authorize",req,resp)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( resp.StatusCode) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( resp.BodyStr) & "</pre>"
%>
</body>
</html>
Curl Command
curl -X POST
-H "Auth-Request-Type: Named-User"
-H "Authorization: Basic <username:password>"
--data-urlencode 'response_type=code_credentials'
--data-urlencode 'client_id={{clientId}}'
--data-urlencode 'redirect_uri={{redirectUrl}}'
https://login.salesforce.com{{site}}/services/oauth2/authorize
Postman Collection Item JSON
{
"name": "Username Password Login - Authorize",
"request": {
"auth": {
"type": "noauth"
},
"method": "POST",
"header": [
{
"key": "Auth-Request-Type",
"value": "Named-User",
"description": "Required for Username Password Login"
},
{
"key": "Authorization",
"value": "Basic <username:password>",
"description": "Base 64 encoded username:password"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "response_type",
"value": "code_credentials",
"type": "text"
},
{
"key": "client_id",
"value": "{{clientId}}",
"type": "text"
},
{
"key": "redirect_uri",
"value": "{{redirectUrl}}",
"type": "text"
},
{
"key": "scope",
"value": "",
"description": "Comma seperated list of scopes, optional",
"type": "text",
"disabled": true
}
]
},
"url": {
"raw": "{{url}}{{site}}/services/oauth2/authorize",
"host": [
"{{url}}{{site}}"
],
"path": [
"services",
"oauth2",
"authorize"
]
},
"description": "This request allows named users to use their username and password to get an access token and refresh token from Salesforce in a headless manner. There are two headers that must be included, the first is the `Auth-Request-Type` which must be set to `Named-User`, and then there is the `Authorization` Basic header which contains the base 64 encoded username:password of the user.\n\nThe result of this API call, is an Auth Code, which is then exchanged with another call at the token endpoint."
},
"response": [
]
}