我试图使用httppost请求获取一个特定的用户OAuth2承载令牌,但似乎没有任何工作。在
login_url = 'https://login.microsoftonline.com/'
authorize_endpoint = '{0}{1}{2}'.format(login_url,config.tenant_id,'/oauth2/authorize')
bodyvals = {'client_id': config.client_id,
'client_secret': config.client_secret,
'grant_type': 'client_credentials',
'resource':config.resource_endpoint}
return requests.post(authorize_endpoint, data=bodyvals)
上述代码正常工作,但代表应用程序生成一个令牌。
我似乎找不到一种方法来传递用户的凭证,也没有任何关于这方面的文档。在
一般来说,我不在乎答案是用Python还是Powershell,或者只是一个一般的解释,我只是不明白如何正确地使用AAD。在
您可以手动完成,请参阅我的另一个答案:https://stackoverflow.com/a/40844983/1658906。在
必须使用
grant_type=password
并调用oauth2/token
端点。以下是用于身份验证的C版本:在请求中,您必须指定:
对于GraphAPI,资源是“https://graph.windows.net/”
如果您不想使用ADAL,那么您可以看看使用“resource”的代码。我们已经讨论了这个场景,所以将ADAL作为一个大样本:)
另外,msrestazure有一个UserPassCredentials实例,它也可以在GraphAPI上运行。在
相关问题 更多 >
编程相关推荐