Home > Enterprise >  OAuth token with basic POST request
OAuth token with basic POST request

Time:04-17

I need to get an OAuth token using a simple POST request.

In Postman, we configure OAuth tokens via the following configuration:

enter image description here

When I click "Get New Access Token", postman makes a request against the Access Token URL.

How does one see what that request looks like? Are these parameters (client id, client secret, etc.) placed in a POST body? What are the headers? I'd like to see the request structure in plain text.

Essentially I need to emulate this request in a script, where I have to include the credentials in the body itself, where the body would look something like this:

{
  "Access_Token_URL":"myURL",
  "Client_ID":"myClientId",
  "Client_Secret":"myClientSecret",
  "Scope":"myScope"
}

CodePudding user response:

That request follows the OAuth 2.0 specification, using the client_credentials grant, and it will use an Authorization Basic header to authenticate the client; so its body will look like this:

POST /token HTTP/1.1
Host: server.example.com
Authorization: Basic bXlDbGllbnRJZDpteUNsaWVudFNlY3JldA
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&scope=MyScope

Where bXlDbGllbnRJZDpteUNsaWVudFNlY3JldA is the Base64-encoded value of myClientId:myClientSecret.

Note that the Content-Type is application/x-www-form-urlencoded.

Also note that what Postman calls the Access Token URL is actually named Token Endpoint in the OAuth 2.0 terminology.

  • Related