2016-12-09 7 views
1

私は個人的には多くの情報があることがわかったので、この情報を見つけるために人生を楽にし、スルー。 OAuth2とMicrosoftログイン https://login.microsoftonline.com/ {アプリ-ID}を使用してOAuth2とマイクロソフトのログインとHTTPリクエストを使用してユーザー名/パスワードでログインする方法

ユーザー名/パスワード(エンドユーザーの資格情報)を使用してログインする方法

/のOAuth2 /トークン

答えて

4

Microsoftは、エンドユーザのユーザ名/パスワード情報を渡すことはお勧めしません。だからこそ彼らはガイドを掲載していません。セキュリティ上の理由から、ログインページにリダイレクトを使用する必要があります。 https://login.microsoftonline.com/ {tenant-id}/oauth2/authorizeを使用してください。

しかし、oauth2 rest APIを使用してこれを行うことは可能であり、非常に簡単です。

Create an http request to 
base url: https://login.microsoftonline.com/{tenant-id}/oauth2/token 
{tenant-id} //obtained from AzureAD config section 

Use the following request parameters in the body section 

grant_type = password //read up on the other grant types, they are all useful, client_credentials and authorization_code 
client_id = {client-id}//obtained from the application section in AzureAD 
client_secret = {client-secret}//obtained from the application section in AzureAD 
resource = https://graph.microsoft.com //there is also the api https://graph.windows.net, use the latest and best one 
username = {enduser-username} //example [email protected] 
password = {enduser-password} //example Hs782f8a 

成功応答がaccess_tokenはを含めると年間2016

推奨リンク

関連する問題