Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/13.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 Partner Center rest api 401错误_Azure_Azure Billing Api - Fatal编程技术网

Azure Partner Center rest api 401错误

Azure Partner Center rest api 401错误,azure,azure-billing-api,Azure,Azure Billing Api,我尝试使用partnercenter api获取账单详细信息。但是API调用返回401错误代码。partnercpi上提供的详细信息是正确的,如果我将其作为Subscription API的输入,则其工作良好 URL:https://api.partnercenter.microsoft.com/v1/customers//subscriptions//usagerecords/resources 你能提出错误的原因吗 参考链接: 这是我的python代码 import adal import

我尝试使用partnercenter api获取账单详细信息。但是API调用返回401错误代码。partnercpi上提供的详细信息是正确的,如果我将其作为Subscription API的输入,则其工作良好

URL:
https://api.partnercenter.microsoft.com/v1/customers//subscriptions//usagerecords/resources

你能提出错误的原因吗

参考链接:

这是我的python代码

import adal
import requests


application_secret = 'asdq23Y+tRgEspFxQDPasd'
application_id = '523129-1267b-123'


authentication_endpoint = 'https://login.microsoftonline.com/'
resource  = 'https://management.core.windows.net/'

context = adal.AuthenticationContext(authentication_endpoint + tenant_id)
token_response = context.acquire_token_with_client_credentials(resource, application_id, application_secret)

access_token = token_response.get('accessToken')


endpoint = "https://api.partnercenter.microsoft.com/v1/customers/<customer tenant ID>/subscriptions/<sub-id>/usagerecords/resources"


headers = {"Authorization": 'Bearer ' + access_token}

json_output = requests.get(endpoint,headers=headers)
print json_output
导入adal
导入请求
应用程序_secret='asdq23Y+tRgEspFxQDPasd'
应用程序id='523129-1267b-123'
身份验证https://login.microsoftonline.com/'
资源管理https://management.core.windows.net/'
context=adal.AuthenticationContext(身份验证\端点+租户\ id)
令牌\u响应=上下文。使用客户端\u凭据(资源、应用程序\u id、应用程序\u机密)获取\u令牌\u
access\u token=token\u response.get('accessToken')
端点=”https://api.partnercenter.microsoft.com/v1/customers//subscriptions//usagerecords/resources"
标头={“授权”:“承载者”+访问令牌}
json_output=requests.get(端点,headers=headers)
打印json_输出
输出响应:

<Response [401]>


此方法是否不适用于partnerapi用法收集?。如果没有,请建议备选方案。提前感谢。

401是因为partner center不能仅使用Azure AD的令牌

实际的身份验证工作流

  • 从Azure广告获取令牌
  • 使用该令牌从PartnerCenter获取访问令牌
  • 使用此令牌与partner center REST API通信

  • 更多信息是因为partner center不能仅使用Azure AD的令牌

    实际的身份验证工作流

  • 从Azure广告获取令牌
  • 使用该令牌从PartnerCenter获取访问令牌
  • 使用此令牌与partner center REST API通信

  • 更多信息

    @gaurav mantri,你知道它为什么返回401未授权访问吗?@gaurav mantri,你知道它为什么返回401未授权访问吗?谢谢你的回复。你有什么样的代码吗?。如果可能的话,请与我分享。我上面提供的链接有一个使用C#解密的示例。我看不出您需要在链接文档上做什么2(从合作伙伴中心获取另一个访问令牌)谢谢您的回复。你有什么样的代码吗?。如果可能的话,请与我分享。我上面提供的链接有一个使用C#进行解密的示例。我看不出您需要在链接文档上做什么2(从Partner Center获取另一个访问令牌)