Using python I did this. But not able to generate tokens that can help to get customer data. Code to get access token
url = "https://login.microsoftonline.com/"+tanat_id+"/oauth2/token"
headers = {
"Accept": "application/json",
"return-client-request-id": "true",
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
"Host": "login.microsoftonline.com",
"Content-Length": "194",
"Expect": "100-continue"
}
data = {
'client_id': client_id,
'resource': 'https://api.partner.microsoft.com',
'client_secret': client_secret,
'grant_type': 'client_credentials',
}
res = requests.post(url, headers=headers, data=data)
access_token = json.loads(res.text)["access_token"]
Code to generate a token
url = "https://api.partnercenter.microsoft.com/generatetoken"
headers = {
"Authorization": "Bearer " + str(access_token),
"Accept": "application/json",
"content-type": "application/json;charset=UTF-8"
}
data = {
'grant_type': 'authorization_code',
}
res = requests.post(url, headers=headers, data={"grant_type":"jwt_token"})
But
>>> res.text
'{"error":"invalid_grant","error_description":"Invalid token: tokenValidationResult == null - True, tokenValidationResult.Principal == null - True, tokenValidationResult.Principal.Identity == null- True, tokenValidationResult.Principal.Identity.IsAuthenticated - "}'
Using access_token if I try to get customer list it returns a 401 error.
#Customer List
url = "https://api.partnercenter.microsoft.com/v1/customers?size=40"
headers = {
"Authorization": "Bearer " + str(access_token),
"Accept": "application/json",
}
res = requests.get(url, headers=headers)
res
<Response [401]>
res.text
""