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.