Invoking Orgarnizational Level APIs in Asgardeo

  • 14 February 2022
  • 0 replies
  • 18 views

Userlevel 3

The recommended way to invoke Organizational level APIs is by retrieving an access token using client_credentials grant type via /oauth2/token endpoint. You can follow the below steps to retrieve an access token.

  1. First, create a Standard-based/Traditional web application with OpenID Connect protocol in the Asgardeo organization using the Asgardeo console.

  2. Go to the Protocol tab and enable the Client Credentials grant type listed in the Allowed grant types section.

  3. Copy the clientID and clientSecret values from the same protocol tab. This is required to invoke /oauth2/token endpoint in Asgardeo to request an access token. 

  4. Below is the sample curl request to retrieve the access token. Also, you can use this postman collection to try out using Postman. Update the clientID, clientSecret, scope values in the token request with the correct values.

Note: You can find the required scopes for each API endpoint from the Asgardeo documentation. If you can’t find the scope for any specific API, you can ask your question in this community portal or you can request help via [email protected] email. :slight_smile:

 

curl --request POST 'https://api.asgardeo.io/t/<organization>/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=<client_id>' \
--data-urlencode 'client_secret=<client_secret>' \
--data-urlencode 'scope=<seperate scopes_with_a_space>'

 

  1. Use the received access token to invoke the organizational level APIs. 

Eg : 

curl --request GET 'https://api.asgardeo.io/t/<org_name>/scim2/Users' \
--header 'Authorization: Bearer <access_token>'

 


0 replies

Be the first to reply!

Reply