Reply
Highlighted
Frequent Visitor
Posts: 3
Registered: ‎02-23-2017
Accepted Solution

microsoft partner center API

[ Edited ]

Hi,

 

So I'm trying to get usage data from Microsoft Partner Center (via web API). I know that I need an Azure token and a Partner Center token to access the data. Connecting to the sandbox partner center environment is no problem (because i'm global admin here). But for the primary environment I can't even get an Azure token. I have registered the Partner Center web API in the Azure active directory. which settings, permissions do I need to change to get the AAD token?

The code below is for the azure token. On the print screen you can see the permissions that I have for the web API. In properties: multi-tenanted = 'no' and I'm not an owner of the api.

 

edit: I can't refresh the tokens for the sandbox environment and still can't get an Azure active directory token for the primary account.

 

Thanks in advance

 

afbeelding.png

 

 

let
    Source = (AccountId as text, ApplicationId as text, ApplicationSecret as text, Password as text, Username as text) => let   
    aadRequest = [
        client_id = ApplicationId, 
        client_secret = ApplicationSecret,
        grant_type = "password",
        password = Password,
        resource = "https://api.partnercenter.microsoft.com",        
        scope = "openid",
        username = Username
    ],
    aadContent = Text.ToBinary(Uri.BuildQueryString(aadRequest)),
    aadTokenRequest = Web.Contents("https://login.microsoftonline.com/" & AccountId & "/oauth2/token", 
        [
            Headers = [#"content-type"="application/x-www-form-urlencoded"], 
            Content = aadContent
        ]
    ),
    aadTokenJSON = Json.Document(aadTokenRequest), 
    aadToken = aadTokenJSON[access_token]
in    
    aadToken
in
    Source

 


Accepted Solutions
Frequent Visitor
Posts: 3
Registered: ‎02-23-2017

Re: microsoft partner center API

Thanks for the replies, but I had to take another route because Partner Center doens't offer a way to automate billing. I can't get prices or reconciliation files via API. So I just have to manually download them. Adding the downloaded files to Power BI is no problem.

View solution in original post


All Replies
Moderator
Posts: 2,173
Registered: ‎03-06-2016

Re: microsoft partner center API

[ Edited ]

matiman wrote:

Hi,

 

So I'm trying to get usage data from Microsoft Partner Center (via web API). I know that I need an Azure token and a Partner Center token to access the data. Connecting to the sandbox partner center environment is no problem (because i'm global admin here). But for the primary environment I can't even get an Azure token. I have registered the Partner Center web API in the Azure active directory. which settings, permissions do I need to change to get the AAD token?

The code below is for the azure token. On the print screen you can see the permissions that I have for the web API. In properties: multi-tenanted = 'no' and I'm not an owner of the api.

 

edit: I can't refresh the tokens for the sandbox environment and still can't get an Azure active directory token for the primary account.

 

Thanks in advance 

 

let
    Source = (AccountId as text, ApplicationId as text, ApplicationSecret as text, Password as text, Username as text) => let   
    aadRequest = [
        client_id = ApplicationId, 
        client_secret = ApplicationSecret,
        grant_type = "password",
        password = Password,
        resource = "https://api.partnercenter.microsoft.com",        
        scope = "openid",
        username = Username
    ],
    aadContent = Text.ToBinary(Uri.BuildQueryString(aadRequest)),
    aadTokenRequest = Web.Contents("https://login.microsoftonline.com/" & AccountId & "/oauth2/token", 
        [
            Headers = [#"content-type"="application/x-www-form-urlencoded"], 
            Content = aadContent
        ]
    ),
    aadTokenJSON = Json.Document(aadTokenRequest), 
    aadToken = aadTokenJSON[access_token]
in    
    aadToken
in
    Source

 


The Power Query code looks good. Does it work in you sandbox while it doesn't work in the primary environment? If yes, let's put the Power Query aside, could you get the token in your primary enviroment by calling that API with C# code or any tool like POSTMAN?

 

I suspect that the problem may be with the Microsoft Partner Center API call. Since this forum is for PowerBI expertise, it doesn't make much sense posting details about the Microsoft Partner Center API, I'd suggest your post your question at the dedicated Microsoft Partner Center community.

Frequent Visitor
Posts: 3
Registered: ‎02-23-2017

Re: microsoft partner center API

I tried connecting on both environments with visual studio (C#) and it works fine.

So I thought I missed some authentication code in power query...

 

Summary:

For sandbox -> Can't refresh

For primary -> Can't get an Azure AD token

 

Thank you for the response. I will post it in the Partner Center community.

 

Moderator
Posts: 2,173
Registered: ‎03-06-2016

Re: microsoft partner center API


matiman wrote:

I tried connecting on both environments with visual studio (C#) and it works fine.

So I thought I missed some authentication code in power query...

 

Summary:

For sandbox -> Can't refresh

For primary -> Can't get an Azure AD token

 

Thank you for the response. I will post it in the Partner Center community.

 


When saying "it works fine", in visual studio do you call the same API as the power query code does, that is to say, you can get an token in C# but not in Power Query? In both enviroment, do you test with the same client_id and client_secrect?

Frequent Visitor
Posts: 3
Registered: ‎02-23-2017

Re: microsoft partner center API

Thanks for the replies, but I had to take another route because Partner Center doens't offer a way to automate billing. I can't get prices or reconciliation files via API. So I just have to manually download them. Adding the downloaded files to Power BI is no problem.