API authorization token generation without postman

Need help to generate API token in my automation tool dynamicaly
All I have got is token URL, client ID and CLient secret.

Please can anyone let me know the POST request body and headers required to generate okta token?

request looks like below:

I can generate the token in Postman authentication, and use it but my requirement is to generate it in my automation tool dynamically for 100s of users.

it’s not possible in general, as it may require 2 requests to be sent, please check List users and groups with and administrator read only account with no login page prompted - #5 by phi1ipp where I provided some example

Thanks for your response. Is it possible to handle this via API request? what will be the request format in such case?Just to make sure, It’s not for a web app but API, how is postman able to generate access token under authorization tab buy single token end point url?

I had another web app there I have no issue in token generation for the web app.

The following format works if your automation tool supports ‘curl’:

curl --location --request POST 'https://{{client}}:{{secret}}@{{oktatenantdomain}}/oauth2/{{authserver}}/v1/token?grant_type=client_credentials' \
--header 'Accept: application/json' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'scope={{scopes-required}}’

replace {{…}} with your values.

Thanks @Prabhakar_D my tool doesn’t support curl but your response helped me to create the right request with few hit and trial on the header :slight_smile:

Based on my experience below were the steps required to generate bearer token. Posting here to help someone in future

  1. The first mistake was not encoding client id and password in Base64.This needs to be passed in header in Base64 encoded format.

authorization: Basic ’

  1. Write clientid:Clientsecret and convert to Base64

  2. Append ?grant_type=client_credentials in your token URL

eg https://xxxxx/oauth2/xxxxxxx/v1/token?grant_type=client_credentials

Body can be blank. Nothing else was required to generate token.

Refer the screenshot below to see how my API Post request header looks to generate token. No authorization request required separately any tool having a capability of sending post request can be used.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.