1

Graph API に対して認証する次の Python コードがあります。

import requests

def login(tenant_name, client_id, client_secret, username, password):
     url = 'https://login.windows.net/' + tenant_name + '/oauth2/token'
     payload = {
             'grant_type': 'password',
             'username': username + '@' + tenant_name,
             'password': password,
             'client_id': client_id,
             'client_secret': client_secret,
             'resource': 'https://graph.windows.net'
     }

     r = requests.post(url, data=payload)

    return r.json()

パスワードの有効期限が切れているユーザーがいる場合、(予想どおり) 応答が返されます。

{
 'timestamp': '2015-09-15 02:59:26Z',
 'trace_id': '8abff845-6941-4867-9729-15626c23330f',
 'submit_url': None, 
 'correlation_id': '81184c06-2627-4bca-82e3-76aab7713a5f', 
 'error_description': 'AADSTS70002: Error validating credentials. AADSTS50055: Password is expired.
Trace ID: 8abff845-6941-4867-9729-15626c23330f
Correlation ID: 81184c06-2627-4bca-82e3-76aab7713a5f
Timestamp: 2015-09-15 02:59:26Z',
 'context': None,
 'error': 'user_password_expired', 
 'error_codes': [70002, 50055]
}

Graph API では、エンドポイントを使用してパスワードをリセットできますが、そのためには有効なトークンが必要です (ドキュメントに記載されているエンドポイントに PATCH 要求を行うため)。ログインできなかったため、トークンを持っていません。

Azure Graph API を使用して有効期限が切れたユーザー パスワードを変更する正しい方法は何ですか?

4

1 に答える 1