- Jean-Louis Bouty
- PowerBuilder
- Tuesday, 3 September 2024 02:26 PM UTC
Hello,
How to get back the user identity from Microsoft Entra ID ?
I have well get the TOKEN :
loac_Client = Create OAuthClient
//TokenRequest
ltr_Request.tokenlocation = "https://login.microsoftonline.com/d2b93004-fa61-4e54-ad68-0114729cb9fb/oauth2/v2.0/token"
ltr_Request.Method = "POST"
ltr_Request.clientid = ls_ClientID
ltr_Request.clientsecret = ls_secret
ltr_Request.granttype = "client_credentials"
ltr_Request.Scope = ls_ClientID + "/.default"
li_rc = loac_Client.AccessToken( ltr_Request, ltr_Response )
And with the token I try to get the user identity :
ls_TokenType = ltr_Response.gettokentype( )
ls_AccessToken = ltr_Response.GetAccessToken()
lnv_RestClient.SetRequestHeader("Authorization", ls_TokenType + " " + ls_AccessToken, true)
ls_urlord = "https://graph.microsoft.com/v1.0/me/user.read"
li_rc = lnv_RestClient.SendRequest("GET", ls_urlord, ls_resp)
But I receive an error with bad token :
{"error":{"code":"InvalidAuthenticationToken","message":"Access token validation failure. Invalid audience.","innerError":{"date":"2024-09-03T14:23:28","request-id":"3e97dd4c-9439-43e6-ad41-91a0a26faf21","client-request-id":"3e97dd4c-9439-43e6-ad41-91a0a26faf21"}}}
Thanks for your help/assistance
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.