Search code examples
office365office365api

Office365 API: get current user email using oauth2 token?


I'm working on authentication for Outlook (office365) users in our web app through ouath2. Mainly I was followed this example: https://dev.outlook.com/RestGettingStarted/Tutorial/python . I managed to get response with access_token in it; also article from the link above, states that response should contain token_id which in turn will contain encoded user email. In my case response with access token is something like this:

{
u'token_type': u'Bearer', 
u'scope': u'https://outlook.office.com/mail.readwrite', 
u'access_token': u'EwB4Aul3BAA...ZQE=', 
u'expires_in': u'3600'
}

Apparently no token_id here. I've googled a bit for some Office365 API which will allow to fetch user info (and email) using access_token but no luck.

Any suggestions?


Solution

  • So, the answer is pretty simple: I forget to add openid to scopes before requesting access token.