Search code examples
office365office365-apps

AuthenticatonError when making requests to Microsoft's Graph API


I am trying to query the Graph API for information on user's calendars. I'm currently able to query /me with no issue:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
    "id": "---",
    "businessPhones": [
        "123456789"
    ],
    "displayName": "john smith",
    "givenName": "john",
    "jobTitle": null,
    "mail": null,
    "mobilePhone": "+123456789",
    "officeLocation": null,
    "preferredLanguage": "en-US",
    "surname": "",
    "userPrincipalName": "person@org.onmicrosoft.com"
}

However, querying for any resource (ie: https://graph.microsoft.com/v1.0/me/calendars) gives the error:

{
    "error": {
        "code": "AuthenticatonError",
        "message": "Error authenticating with resource",
        "innerError": {
            "request-id": "de91f00f-fd39-44cc-8856-757dc4a5ee24",
            "date": "2016-07-22T14:11:04"
        }
    }
}

I've been googling any nobody else seems to have this issue. My app is properly registered and has every permission enabled. I am calling the API via Angular with ADAL. The app gets the token and authenticates with no issue (isAuthenticated: true in the userInfo) Has anyone else experienced this issue?


Solution

  • Ended up solving this issue by ditching the graph api and querying https://outlook.office365.com/api/v1.0/me/calendars. The docs at https://msdn.microsoft.com/en-us/office/office365/api/calendar-rest-operations?f=255&MSPPError=-2147217396#GetCalendarView appear to have the incorrect api endpoints.

    Our app's version of Angular is 1.2 and the version of adal.js is 1.0.7. Instead of using Azure AD, I used the registration @ dev.outlook.