Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure 为什么ADAL token返回的token显示未经邮递员授权的请求,我如何解决?_Azure_Azure Active Directory_Adal_Azure Blockchain Workbench - Fatal编程技术网

Azure 为什么ADAL token返回的token显示未经邮递员授权的请求,我如何解决?

Azure 为什么ADAL token返回的token显示未经邮递员授权的请求,我如何解决?,azure,azure-active-directory,adal,azure-blockchain-workbench,Azure,Azure Active Directory,Adal,Azure Blockchain Workbench,我想从我的python应用程序对Azure区块链工作台进行API调用。为此,API调用需要授权持有者。当我使用Inspect元素从Azure UI Webapp获取承载时,相同的令牌承载可以很好地处理API调用。 但是,在API调用中使用时,Python中ADAL返回的承载显示401 unauthorized 对于Inspect元素部分,我通过登录到然后使用Inspect元素来获取令牌 在python部分,这里是我的代码 导入adal 导入swagger_客户端 从swagger_client.

我想从我的python应用程序对Azure区块链工作台进行API调用。为此,API调用需要授权持有者。当我使用Inspect元素从Azure UI Webapp获取承载时,相同的令牌承载可以很好地处理API调用。 但是,在API调用中使用时,Python中ADAL返回的承载显示401 unauthorized

对于Inspect元素部分,我通过登录到然后使用Inspect元素来获取令牌

在python部分,这里是我的代码

导入adal
导入swagger_客户端
从swagger_client.api_client导入ApiClient
上下文=adal.AuthenticationContext(“https://login.microsoftonline.com/kumarshobhit98outlook.onmicrosoft.com/,api_版本=无)
客户_id=“c62087b9-cfed-4105-a9c2-4fd3953ceed5”
res='c80344c2-d7fc-41e1-adcc-dd33683a7f6b'
令牌=上下文。使用\u用户名\u密码获取\u令牌(资源=)https://graph.windows.net“,用户名=”shobhit@kumarshobhit98outlook.onmicrosoft.com,password=“pass”,client\u id=client\u id)
打印(令牌['accessToken'])

我想用python获得一个身份验证承载器,我可以在API调用中进一步使用它。

资源的值不正确,要让访问令牌访问您的API,您应该使用客户端id作为值

token = context.acquire_token_with_username_password(resource=client_id,username="shobhit@kumarshobhit98outlook.onmicrosoft.com",password="pass",client_id=client_id)