OAuth2 Client Credentials flow.
Client Credentials flow is one of the OAuth2 flows.
Prerequisites:
- Make sure you have a client and client secret.
How to get token by client credentials grant?
Send a client credentials grant request with the code from the previous step . Request params are as following:
grant_type:client_credentialsscope: list of scopes which you want to include.client_idandclient_secretto use in basic authentication method. its value should be base64 value ofclient_id:client_secret. To generate the base64 value of yourclinet_idandclient_secretyou can use following command in osx or linux:
echo -n your_client_id:your_client_secret | base64
Here is an example of this request:
curl --location --request POST 'localhost:4000/oauth2/token' \
--header 'Authorization: Basic MjAyMjEyMzE0MTgxMC53NWV2aXZ1eWtneGt4eXU6bXlfY2xpZW50X3NlY3JldA==' \
--form 'grant_type="client_credentials"' \
--form 'scope="all"'
You will get a response like this:
{
"access_token": "601hpj8n01ndycdl8pxve3t1n03kjg",
"expires_in": 2592000,
"scope": "all",
"token_type": "Bearer"
}
Now you can use the token.