I am consuming one post API and getting one auth token to use get data from other API so I just wanted to ask where Can use this auth token or how can use this auth token to find the authorize User

0
I am consuming one post API and getting one auth token to use get data from other API so I just wanted to ask where Can use this auth token or how can use this auth token to find the authorize User. and also  I am using that token to get data from API in postman I am able to get the data but when I am consuming the API in Mendix there status code is coming 200 but not getting the data in Mendix
asked
3 answers
1

Hi Aditya Bhat,

For what I understand are you retrieving an access token from an Identity Provider (IdP) which use can use to authenticate at another API, the service provider (SP).

The response of retrieving such an access token mostly looks like a JWT:

{
  "access_token":"eyJz93a...k4laUWw",
  "token_type":"Bearer",
  "expires_in":86400
}

 

You can create an import mapping within Mendix to store these values in an object, let's call this $AccessTokenResponse and then use this in your next call by using the access_token attribute.

 

In a plain "Call REST" activity, you need to add an HTTP Header name 'Authorization' and fill this with

'Bearer ' + $AccessTokenResponse/access_token

 

In Mendix 10.21, you can use a Consumed REST Service, as Paul says. You then first add a parameter, which you call for example access_token, and then add a header Authorization with the value Bearer {access_token}, see screenshots below. This makes reuse easier if you want to call multiple endpoints of this service provider API.

image.png

image.png

 

Good luck!

answered
1

If it is an OAuth2.0 authorization flow you can also take a look at: https://stephanbruijnis.dev/docs/how-to/connect-your-mendix-application-to-apis-secured-with-oauth-2.0-authorization/ which describes the concepts and steps required to get an authorization code, and the bearer tokens (access+refresh token). 

 

Wij van WC-eend adviseren WC-eend =)

answered
0

Hello Aditya,

Please check this if help.

Configuring REST services in Mendix | by Ryan Mocke | Mendix Community | Medium

Mendix Community - Question Details

Mendix Community - Question Details

answered