问题描述
Hi Team,
我使用下面的python代码来获取订阅的配置状态但获得403响应。想知道这里可能出现什么问题。
I am using below python code to get subscription's provisioningstatus but getting 403 response. Wondering what could be going wrong here.
app_id =" *************************** ******< b $ b app_sec =" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^"
$
reseller_domain =" !!!!!!!!!!!!!!!!!!!!"
$
Authority =" https://login.windows.net"
$
ResourceUrl =" https://graph.windows.net"
url =权限+" /" + reseller_domain +" / oauth2 / token"
content = {" grant_type":" client_credentials"," client_id":app_id,
&NBSP; &NBSP; " client_secret":app_sec," resource":ResourceUrl}
headers = {" Content-Type":" application / x-www-form-urlencoded"}
r = requests.post(url,data = content,headers = headers,verify = False)
access_token =无
如果r.status_code == 200:
&NBSP; accessToken = r.json()[" access_token"]
&NBSP; url =" https://api.partnercenter.microsoft.com/generatetoken"
&NBSP; headers = {" Authorization":" Bearer" + accessToken,"Content-Type":" application / x-www-form-urlencoded"}
&NBSP; content = {" grant_type":" jwt_token"}
&NBSP; r = requests.post(url,data = content,headers = headers,verify = False)
&NBSP;如果r.status_code == 200:
&NBSP; &NBSP; &NBSP; access_token = r.json()[" access_token"]
$
如果access_token:
&NBSP; guid = str(uuid.uuid4())
&NBSP; guid1 = str(uuid.uuid4())
&NBSP; headers = {" Authorization":" Bearer" + access_token," Accept":"application / json","MS-RequestId":guid,"MS-CorrelationId":guid1}
  ; &NBSP; url =" https://api.partnercenter.microsoft.com/v1/customers/" + customerId +" ;/ subscriptions /&\"+ subscriptionId +" / provisioningstatus"
$
&NBSP; response = requests.get(url,headers = headers,verify = False)
&NBSP;打印回复
&NBSP;打印response.status_code
&NBSP; print response.text
app_id = "*********************************"
app_sec = "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
reseller_domain = "!!!!!!!!!!!!!!!!!!!!"
Authority = "https://login.windows.net"
ResourceUrl = "https://graph.windows.net"
url = Authority + "/" + reseller_domain + "/oauth2/token"
content = {"grant_type": "client_credentials", "client_id": app_id,
"client_secret": app_sec, "resource": ResourceUrl}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
r = requests.post(url, data=content, headers=headers, verify=False)
access_token = None
if r.status_code == 200:
accessToken= r.json()["access_token"]
url = "https://api.partnercenter.microsoft.com/generatetoken"
headers = {"Authorization": "Bearer " + accessToken, "Content-Type": "application/x-www-form-urlencoded"}
content = {"grant_type": "jwt_token"}
r = requests.post(url, data=content, headers=headers, verify=False)
if r.status_code == 200:
access_token = r.json()["access_token"]
if access_token:
guid = str(uuid.uuid4())
guid1 = str(uuid.uuid4())
headers = {"Authorization": "Bearer " + access_token, "Accept": "application/json", "MS-RequestId": guid, "MS-CorrelationId": guid1}
url = "https://api.partnercenter.microsoft.com/v1/customers/" + customerId + "/subscriptions/"+subscriptionId+"/provisioningstatus"
response = requests.get(url, headers=headers, verify=False)
print response
print response.status_code
print response.text
回复: -
<响应[403]>
403
无
<Response [403]>
403
None
注意: - customerId和 subscriptionId有效
Note:- customerId and subscriptionId are valid
推荐答案
此方案仅支持使用App +用户凭据进行身份验证。
This scenario supports authentication with App+User credentials only.
更多信息,请参阅在这里:
More information is here:
最好的问候,
Dennis
这篇关于partnerCenter订阅provisioningstatus api authantication的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!