143
Views
7
Comments
Solved
Consume Rest API
Application Type
Reactive

Hello everyone,

I am consuming the Microsoft Azure AD token Rest API, but whenever I test the rest API in Outsystems then I get this error. I can't specify why it throws this error "invalid_request". Can anyone help me resolve this problem.

Thanks,

2021-10-09 07-57-44
Stefan Weber
 
MVP
Solution

Hi,

The endpoint you have specified in your request is the OAuth Token Endpoint Url of the Microsoft Identity Platform. The token endpoint is responsible for the following operations

  • Exchanging a grant for an access token and optional identity token and refresh token
  • Refreshing an access token using an existing and valid refresh token.

Exchanging a grant

You can get an access token via the following grant_types

  • Client Credentials - You exchange Client Id and Client Secret of your registered application for an access token (identity token and refresh tokens are not available using this grant_type)
  • Resource Owner - You exchange Username and Password for an access token
  • Authorization Code - You exchange an Authorization Code received from the Identity Platform after User based authentication and consent via a redirect to your application

The token endpoint url accepts POST requests via application/x-www-form-urlencoded content type.

For requesting an access token by client credentials you have to provide the following parameters.

  • grant_type - set to client_credentials
  • client_id - set to the identfier of your registered application
  • client_secret - set to the secret of your registered application
  • scope - space delimited scopes granting access to other services (resources) e.g. Graph API on application level

The body of the request would look like the following

grant_type=client_credentials&client_id={ClientId}&client_secret={ClientSecret}&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default

Note: Scope must be URL encoded!

After a successful request you will receive an access_token and expires_in along with a token_type (always Bearer).

Best

Stefan

2024-05-07 09-21-36
Rakhi Chouhan

Thankyou @Stefan Weber  it works now.


2021-08-12 05-19-40
Shubham Janbandhu

Hi Rakhi Singh,

Hope you are doing well.

Check the error details, seems like the Rest API is POST method and request body must contain the following parameters. In screenshot request body is empty. Provide some parameters and then verify. Hope this helps.





Regards,

Shubham

2024-05-07 09-21-36
Rakhi Chouhan

Hi,
I already try that whatever you are saying but it does not work. 

Thanks

2020-09-21 11-35-56
Sachin Waghmare

Hello Rakhi,

Based on the error description it looks like you are missing something or sending request parameters incorrectly. You may need to pass "Grant_Type" into the request. Can you please validate all your request parameters or try with postman?

Thanks,

Sachin 

2024-05-07 09-21-36
Rakhi Chouhan

Hi 

I tried all the parameters with postman and there it works fine, but it throws error in outsystems.

2021-10-09 07-57-44
Stefan Weber
 
MVP
Solution

Hi,

The endpoint you have specified in your request is the OAuth Token Endpoint Url of the Microsoft Identity Platform. The token endpoint is responsible for the following operations

  • Exchanging a grant for an access token and optional identity token and refresh token
  • Refreshing an access token using an existing and valid refresh token.

Exchanging a grant

You can get an access token via the following grant_types

  • Client Credentials - You exchange Client Id and Client Secret of your registered application for an access token (identity token and refresh tokens are not available using this grant_type)
  • Resource Owner - You exchange Username and Password for an access token
  • Authorization Code - You exchange an Authorization Code received from the Identity Platform after User based authentication and consent via a redirect to your application

The token endpoint url accepts POST requests via application/x-www-form-urlencoded content type.

For requesting an access token by client credentials you have to provide the following parameters.

  • grant_type - set to client_credentials
  • client_id - set to the identfier of your registered application
  • client_secret - set to the secret of your registered application
  • scope - space delimited scopes granting access to other services (resources) e.g. Graph API on application level

The body of the request would look like the following

grant_type=client_credentials&client_id={ClientId}&client_secret={ClientSecret}&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default

Note: Scope must be URL encoded!

After a successful request you will receive an access_token and expires_in along with a token_type (always Bearer).

Best

Stefan

2024-05-07 09-21-36
Rakhi Chouhan

Thankyou @Stefan Weber  it works now.


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.