How to get userinfo with Microsoft OAuth after suc

2019-08-09 10:53发布

问题:

My applications should login with Microsoft account (OAuth Provider). I got stuck to get user info after successfully authenticated by using following URL https://login.live.com/oauth20_authorize.srf?client_id=CLIENT_ID&scope=SCOPES&response_type=code&redirect_uri=REDIRECT_URL Can any one please help me to get user-info? Is there any library that I need to include for that ? I'm getting authenticated code but I don't know how use ? I'm working with JAVA

回答1:

The userinfo endpoint is https://apis.live.net/v5.0/me. Before you call it you need to exchange the code for a token.



回答2:

For anyone stumbling here.

OpenID discovery URL: https://login.live.com/.well-known/openid-configuration

Microsoft doesn't provide userinfo_endpoint in the service configuration json

UserInfo URL : https://graph.microsoft.com/v1.0/me

Make a GET request to this url with header containing access_token that you got after exchanging auth_code

Key: Authorization

Value: Bearer <access_token>