为什么 ADAL 令牌返回的令牌在 Postman 发出的请求中显示未经授权,我该如何解决?
Why is the token returned by ADAL token showing unauthorised on a request made by Postman and how do i resolve it?
我想从我的 python 应用程序对 Azure 区块链 Workbench 进行 API 调用。为此,API 调用需要授权承载。当我使用 Inspect Element 从 Azure UI Webapp 获取承载时,相同的令牌承载可以很好地处理 API 调用。
但是,ADAL 在 Python 中返回的承载在 API 调用中使用时显示 401 未授权。
对于检查元素部分,我通过登录 https://votemaadi-4bm4ew.azurewebsites.net 然后使用检查元素来获取我的令牌。
在python部分,这是我的代码
import adal
import swagger_client
from swagger_client.api_client import ApiClient
context = adal.AuthenticationContext("https://login.microsoftonline.com/kumarshobhit98outlook.onmicrosoft.com/",api_version=None)
client_id="c62087b9-cfed-4105-a9c2-4fd3953ceed5"
res='c80344c2-d7fc-41e1-adcc-dd33683a7f6b'
token = context.acquire_token_with_username_password(resource='https://graph.windows.net',username="shobhit@kumarshobhit98outlook.onmicrosoft.com",password="pass",client_id=client_id)
print(token['accessToken'])
我想在 python 中获得身份验证承载,我可以在 API 调用中进一步使用它。
资源值不正确,要让访问令牌访问您的api,您应该使用client_id作为值。
token = context.acquire_token_with_username_password(resource=client_id,username="shobhit@kumarshobhit98outlook.onmicrosoft.com",password="pass",client_id=client_id)
我想从我的 python 应用程序对 Azure 区块链 Workbench 进行 API 调用。为此,API 调用需要授权承载。当我使用 Inspect Element 从 Azure UI Webapp 获取承载时,相同的令牌承载可以很好地处理 API 调用。 但是,ADAL 在 Python 中返回的承载在 API 调用中使用时显示 401 未授权。
对于检查元素部分,我通过登录 https://votemaadi-4bm4ew.azurewebsites.net 然后使用检查元素来获取我的令牌。
在python部分,这是我的代码
import adal
import swagger_client
from swagger_client.api_client import ApiClient
context = adal.AuthenticationContext("https://login.microsoftonline.com/kumarshobhit98outlook.onmicrosoft.com/",api_version=None)
client_id="c62087b9-cfed-4105-a9c2-4fd3953ceed5"
res='c80344c2-d7fc-41e1-adcc-dd33683a7f6b'
token = context.acquire_token_with_username_password(resource='https://graph.windows.net',username="shobhit@kumarshobhit98outlook.onmicrosoft.com",password="pass",client_id=client_id)
print(token['accessToken'])
我想在 python 中获得身份验证承载,我可以在 API 调用中进一步使用它。
资源值不正确,要让访问令牌访问您的api,您应该使用client_id作为值。
token = context.acquire_token_with_username_password(resource=client_id,username="shobhit@kumarshobhit98outlook.onmicrosoft.com",password="pass",client_id=client_id)