Graph API throwing : Access token validation failure


  • I am trying to integrate Graph API for organization level. Using ng2-adal (Angular 2), I'm authenticating the users and it's authenticate user successfully. Using access_token, am trying to get user's profile by calling 

    getUserProfile(): Observable<any> {
    // Perform REST call into Microsoft Graph for files on OneDrive for Business
    const access_token =
    return this.http.get('', {
    headers: new Headers({ 'Authorization': 'Bearer ' + access_token })
    }).map((response: Response) => {
    return response.json();

    Getting response as:

      "error": {
        "code": "InvalidAuthenticationToken",
        "message": "Access token validation failure.",
        "innerError": {
          "request-id": "8595528a-8841-4982-9be3-f0c1a0b7416b",
          "date": "2017-04-12T09:09:53"

    Wednesday, April 12, 2017 9:19 AM

All replies

  • I am using ng2-adal and connecting to MS Graph. I think it is likely your access token is wrong or is expired.

    You'll want to use the authHttp service that ng2-adal has. In the config object, you need something like this:

    endpoints: {
    "": ""

    Then when you do a call to the API, use the authHttp methods instead of Angular's http. authHttp will handle the access token part for you while automatically adding it to the headers.

    You also have to register your app and MS Graph correctly with AD giving your app the right permissions to access resources from MS Graph. The process will vary depending on if you are using the Azure AD v2.0 endpoint or not.

    Friday, April 14, 2017 4:14 PM
  • Looking at the token you have provided.  The audience is for the application, not the resource.  You should be able to take the code you received when you authenticated the user and request a token for the user with the resource, basically, an on behalf of flow.

    Here is the payload of the token provided:
      "aud": "8c907c91-1b21-4468-825e-116a4f663249",
      "iss": "",
      "iat": 1491987296,
      "nbf": 1491987296,
      "exp": 1491991196,
      "amr": [
      "family_name": "Rengarajan",
      "given_name": "Praveen",
      "ipaddr": "",
      "name": "Praveen Rengarajan",
      "nonce": "c237f265-2842-458a-a380-8b871f94eafe",
      "oid": "c8cf4156-6f31-4a05-bf6c-88cec87b598e",
      "onprem_sid": "S-1-5-21-1518476537-3756393031-1079764384-9950",
      "platf": "3",
      "sub": "r5cyIprh0HUSpBJSyszz8QMxNAuT3Wtg25g1tjb_G6k",
      "tid": "77428205-87ff-4048-a645-91b337240228",
      "unique_name": "",
      "upn": "",
      "uti": "mBynQx0vBkSTeXmTweQVAA",
      "ver": "1.0"

    Notice the aud: claim, it is the application ID.  Not the resource.  When I looked at the operations logs, the request was rejected for just this reason, the audience was not correct for the token, so it can't be used to access the resource.

    Here is a link to the OAuth documentation that may help you create the request for a bearer token for the resource:

    MaxV (MSFT)

    Wednesday, April 19, 2017 8:29 PM
  • How should I enable in my adaljs. I am using angular2 adal service for authentication. It's giving me id_token.
    Thursday, May 4, 2017 6:40 AM