0
votes

I am trying to integrate office 365 apis with my application. I am able to generate the access token using the OAuth2 process. But calling the api with that generated access token is giving us a 401 error.

This is the response of token I am getting

{
    "token_type": "Bearer",
    "scope": "ActivityReports.Read ThreatIntelligence.Read",
    "expires_in": "3599",
    "ext_expires_in": "0",
    "expires_on": "1480350031",
    "not_before": "1480346131",
    "resource": "https://manage.office.com",
    "access_token": "===access token===",
    "refresh_token": "===refresh token===",
    "id_token": ""
}

And I am trying to call the endpoint "https://outlook.office.com/api/v2.0/me" with the header as Authorization: Bearer , but giving me the 401 error.

Any thoughts ?

Thanks,

1

1 Answers

0
votes

I believe the issue here is that you have acquired an access token for an endpoint that is different than the API you are trying to query. If you notice, the "resource" in your token is "manage.office.com" when you will need a token with the resource "outlook.office.com" in order to query the outlook API.

Can you check in your code that you are specifying the correct resource for your needs, and additionally, make sure your client application is configured correctly for the permissions required to access that API.

I hope this helps!