English 中文(简体)
Microsoft partner API: can t authenticate
原标题:

I ve created an app in Azure AD and followed this steps (Application and user access): https://github.com/MicrosoftDocs/partner-rest/blob/docs/partner-rest/develop/api-authentication.md

From what I understand the Microsoft Partner API only works with MFA, so I can t authenticate using username + password to https://login.microsoftonline.com.

To get an access_code, I perform these steps:

  1. Open the url in my browser: https://login.microsoftonline.com/TENANT_ID/oauth2/v2.0/authorize?client_id=CLIENT_ID&response_type=code&redirect_uri=https://****/test.php&response_mode=form_post&scope=offline_access%20openid%20profile%20User.Read&state=1

  2. On the callback url, I receive a code, which I use to request the access_code. I perform the following request:

curl --request POST  https://login.microsoftonline.com/TENANT_ID/oauth2/token  
--header  Content-Type: application/x-www-form-urlencoded  
--data-urlencode  grant_type=authorization_code  
--data-urlencode  client_id=CLIENT_ID  
--data-urlencode  client_secret=CLIENT_SECRET  
--data-urlencode  resource=https://api.partner.microsoft.com  
--data-urlencode  code=CODE_FROM_PREVIOUS_REQUEST  
--data-urlencode  redirect_uri=https://****/test.php 

Now I have the access_code and the refresh_token

  1. This is where I m stuck, I use the access_token in the following request:
curl --request GET  https://api.partnercenter.microsoft.com/v1/customers  
--header  Authorization: Bearer ACCESS_TOKEN 

But I get an 401 invalid_grant error. I also found this article from a similar problem, but that didn t help.

问题回答

Try to use a refresh_token in the call to the Partner Center API instead of an ACCESS_TOKEN. I had a similar issue and was able to bypass the 401 invalid_grant error with this.





相关问题
Windows Azure WorkerRole response

I am working on an Azure demo to run Powershell in a worker role. In my web role I add the name of the Powershell script which is to be run to a CloudQueue object. I can print the script output to ...

Windows Azure WebRole stuck in a deployment loop

I ve been struggling with this one for a couple of days now. My current Windows Azure WebRole is stuck in a loop where the status keeps changing between Initializing, Busy, Stopping and Stopped. It ...

Getting a token for Windows Azure

We are looking at Windows Azure, but getting a token appears to be hard now, at least that s what I m seeing in web searches. Anyone tried it or know how to accelerate that process? Any idea how long ...

Developing Azure .Net 4.0 Applications

Presently .Net 4.0 is not supported on Azure. This thread indicates that you will not be able to use .Net 4.0 with VS 2010 until it is supported in the cloud. http://social.msdn.microsoft.com I d ...

.NET 4.0 on Windows Azure?

My google-fu is failing me on this one. As a possible solution to Unit Testing .NET 3.5 projects using MStest in VS2010 (but I ve put this in a seperate question because it s kind of unrelated): Is ...

热门标签