0
votes

I'm trying to get the users basic profile from Azure AD. I have a React Native app authenticating against a Native Azure AD App registration. The access_token I got from that request is used to authenticate against a Web app / Api. The user is shown the propper consent screen with the permissions I set in Azure AD.

  1. Microsoft Graph API
    • Read all users' basic profiles
    • Sign in and read user profile
  2. Windows Azure Active Directory
    • Read all users' basic profiles
    • Sign in and read user profile

(added both Graph API & AAD because I didn't know which one to use)

When I try and get the users profile through https://graph.microsoft.com/v1.0/users/me, with the access_token gotten from the previous request I get:

{
    "error": {
        "code": "InvalidAuthenticationToken",
        "message": "Access token validation failure.",
        "innerError": {
            "request-id": "00cdb708-bcf8-4b33-af21-14a046b16533",
            "date": "2018-09-02T18:28:59"
        }
    }
}

The resource in my initial authentication request is the Web App / API's app id, and I don't think having 2 resources is an option (?).

What am I doing wrong, and what should I do to fix it? Thanks.

2

2 Answers

1
votes

According to your descriptions, I assume you want to get the users profile, but get the error shows an invalid token.

Based on my test, the request URL that you posted is not correct.

It should be 'https://graph.microsoft.com/v1.0/me' or 'https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}'.

We can trouble shoot your problems as follows.

First, check request, if it has correct 'Authorization' field. This document shows that we need the Authorization field in the request headers.

Second, if you have added the Authorization field in the request headers, could you provide the main code that we can identify if problem is from there ?

0
votes

While getting the access token add "resource" : "https://graph.microsoft.com/" and use that access token in header with Bearer than hit the url ---> https://graph.microsoft.com/me?api-version=1.6

Don't forget to add the resource while getting access token

Thank me later :P