Get auth token microsoft graph api

Hi all   This might be the wrong place to ask this but I need help. I am trying to implement this → ( in my mendix application. Basically I want to get an access token so that any user can call post and get requests. It’s very confusing and I’m not sure how to retrieve the responses exactly, I’m not even sure if this guide even works in mendix, does anybody know how to implement this exactly or has someone already done it maybe?   Thanks
1 answers

Hi Lenny,

We've implemented this a few days ago. The basics is just 2 REST calls, a POST for retrieving your access token, and then you use this token as a header in following POST or GET requests.


First get the token with a REST POST, using the Location{1}/oauth2/v2.0/token (where {1} is your tenantID). As requestcontent you can use:

'client_id=' + $ClientID +
&client_secret=' + $Secret +

We configured the following Http Header:

You will get the following response structure:

You can then use the Access_token in the actual REST call you want to do as a HTTP header:

Note that the token can expire, so you will have to check if your token is still valid before doing the second call, if there is some time between them. The expires_In field shows in how many seconds the token will expiry, so it is useful to also store a creationdate.

Hope this helps.