Search code examples
talend

Get token from API Microsoft Graph


How to get the token from en API Microsoft Graph from a Talend job? Under postman it's ok to generate the token but with a tRest component I don't know what kind of parameters I should use and where. All I get is a status200 answer that ask me to sign in.

I tried multiple kind of connection with tRest. Adding a xml body too. If I use the token from postman with a classic API call in Talend, for exemple https://graph.microsoft.com/v1.0/me, it works. So I need to get first the token.


Solution

  • You can do this with the below workflow: tREST -> tExtractJson -> tSetGlobalVar

    workflow

    As per the Microsoft documentation, tREST configuration is as per the below (with client secret): enter image description here

    Replace the yellow bits with your own details.

    Then extract your token from the response body and save it into globalMap for future use.

    If you use other methods than shared secret to identify, look at the Microsoft Graph API documentation Get a Token to see what information you need to send in your POST request.