Partner-Center-PowerShell icon indicating copy to clipboard operation
Partner-Center-PowerShell copied to clipboard

Price sheets partner center issue: 401, Unauthorized: Invalid Authorization header

Open 0nBernard opened this issue 3 years ago • 16 comments

Hi

I am attempting to do an API call to the following: https://learn.microsoft.com/en-us/partner-center/develop/get-a-price-sheet To get a price sheet for a given market and view. But i can not make it work.

I'm able to generate a refresh & access token via powershell, but when I try to call the following API: https://api.partner.microsoft.com/v1.0/sales/pricesheets(Market='be',PricesheetView='updatedlicensebased')/$value

I get a 401, Unauthorized: Invalid Authorization header

My role is Admin Agent on the environment

Can someone help me out?

0nBernard avatar Jan 18 '23 15:01 0nBernard

I am running into the same problem, did you ever find a solution? This issue has been puzzling me. Other calls to the API which require App + User auth go through just fine, but when I try to get a price sheet or offer matrix I get a 401 unauthorized error. I am also Admin Agent on the envrionment.

EdNawrocki avatar Aug 29 '23 21:08 EdNawrocki

Hi...

Did you solve the issue? I have same situation here... I can access all other API calls of the api.partnercenter.microsoft.com with my access_token/refresh_token but get a 401 Unauthorized when calling the pricesheets API. Also I'm Admin Agent.

Thanks.

rarigita avatar Sep 05 '23 11:09 rarigita

No luck yet. I will continue looking into this and report back if I have any success.

EdNawrocki avatar Sep 05 '23 15:09 EdNawrocki

Hi, I made some advance: Using the refresh_token generated with the authorization_code we request a new access_token. Inspecting the access_token on jwt.io we found its "aud":"https://api.partnercenter.microsoft.com", and with that token we get the 401 response from the pricesheets APIs. We thought it was the issue. So we made a test and added "&resource=https://api.partner.microsoft.com" to the next access_token request from refresh_token, and inspecting the token we see "aud":"https://api.partner.microsoft.com". So now we used this new token in the Authorization header of the pricesheet API and it worked, but only with one of the two files we want to dowload:

Response 200 OK: https://api.partner.microsoft.com/v1.0/sales/pricesheets(Market='ES',PricesheetView='updatedlicensebased')/$value -> Receive the CSV data correcty

400 Malformed: https://api.partner.microsoft.com/v1.0/sales/pricesheets(Market='ALL',PricesheetView='legacy_license_based')/$value

Now we don't get a 401 on both requests, but the legacy_license_based gives a 400 Error and a message of Wrong Pricesheet or malformed Headers.

Its weird as I inspected the same requests from the https://partner.microsoft.com/dashboard while click on pricesheet download, and inspecting the Bearer token it looks very similar to the one I generate from my refresh_token. If I copy the web token, it works with my curl CLI request and I get the legacy_license_based without issues, but that Bearer token is generated by the partner web appId, not with our appId and our refresh_token.

Do you understand? Now my issue is how to get the legacy_license_based pricesheet, as I don't know where to look for this.

rarigita avatar Sep 07 '23 09:09 rarigita

rarigita I Follow your Instruction and I resolve my Issue Thanks.

Danishminhas12 avatar Jan 24 '24 06:01 Danishminhas12

@Danishminhas12 can you show me how you got your working? I happen to be using the sample Partner Consent and CSPApplication recommended on here : https://learn.microsoft.com/en-us/partner-center/developer/partner-center-authentication. I also tried to add "&resource=https://api.partner.microsoft.com/" to the request that retrieves the access token, but that return s null.

abrantie11z avatar Jan 26 '24 17:01 abrantie11z

Sure we do a meeting will guide you.

On Fri, 26 Jan 2024, 22:29 Godfred, @.***> wrote:

@Danishminhas12 https://github.com/Danishminhas12 can you show me how you got your working? I happen to be using the sample Partner Consent and CSPApplication recommended on here : https://learn.microsoft.com/en-us/partner-center/developer/partner-center-authentication . I also tried to add "&resource=https://api.partner.microsoft.com/" to the request that retrieves the access token, but that return s null.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/Partner-Center-PowerShell/issues/405#issuecomment-1912422318, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFPO62CMBCELMRZ2PCIGA6DYQPRYFAVCNFSM6AAAAAAT7GUTRKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJSGQZDEMZRHA . You are receiving this because you were mentioned.Message ID: @.***>

Danishminhas12 avatar Jan 26 '24 17:01 Danishminhas12

@abrantie11z contact with me through email i will share screen and show you how i access.

Danishminhas12 avatar Jan 26 '24 17:01 Danishminhas12

Thank You @Danishminhas12 . Can you please share your email here?

abrantie11z avatar Jan 29 '24 11:01 abrantie11z

@abrantie11z [email protected]

Danishminhas12 avatar Jan 29 '24 11:01 Danishminhas12

@Danishminhas12 I did not hear from you again..

abrantie11z avatar Jan 30 '24 10:01 abrantie11z

Hey sorry i am busy in one project today i will contact with you sure.

On Tue, 30 Jan 2024 at 15:04, Godfred @.***> wrote:

@Danishminhas12 https://github.com/Danishminhas12 I did not hear from you again..

— Reply to this email directly, view it on GitHub https://github.com/microsoft/Partner-Center-PowerShell/issues/405#issuecomment-1916486366, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFPO62GAR7BDREUWKHNRTKTYRDAUHAVCNFSM6AAAAAAT7GUTRKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJWGQ4DMMZWGY . You are receiving this because you were mentioned.Message ID: @.***>

Danishminhas12 avatar Jan 30 '24 10:01 Danishminhas12

Sorry for that.

On Tue, 30 Jan 2024 at 15:05, d mehmood @.***> wrote:

Hey sorry i am busy in one project today i will contact with you sure.

On Tue, 30 Jan 2024 at 15:04, Godfred @.***> wrote:

@Danishminhas12 https://github.com/Danishminhas12 I did not hear from you again..

— Reply to this email directly, view it on GitHub https://github.com/microsoft/Partner-Center-PowerShell/issues/405#issuecomment-1916486366, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFPO62GAR7BDREUWKHNRTKTYRDAUHAVCNFSM6AAAAAAT7GUTRKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJWGQ4DMMZWGY . You are receiving this because you were mentioned.Message ID: @.***>

Danishminhas12 avatar Jan 30 '24 10:01 Danishminhas12

Ok, hanging on

abrantie11z avatar Jan 30 '24 12:01 abrantie11z

Hi, I made some advance: Using the refresh_token generated with the authorization_code we request a new access_token. Inspecting the access_token on jwt.io we found its "aud":"https://api.partnercenter.microsoft.com", and with that token we get the 401 response from the pricesheets APIs. We thought it was the issue. So we made a test and added "&resource=https://api.partner.microsoft.com" to the next access_token request from refresh_token, and inspecting the token we see "aud":"https://api.partner.microsoft.com". So now we used this new token in the Authorization header of the pricesheet API and it worked, but only with one of the two files we want to dowload:

Response 200 OK: https://api.partner.microsoft.com/v1.0/sales/pricesheets(Market='ES',PricesheetView='updatedlicensebased')/$value -> Receive the CSV data correcty

400 Malformed: https://api.partner.microsoft.com/v1.0/sales/pricesheets(Market='ALL',PricesheetView='legacy_license_based')/$value

Now we don't get a 401 on both requests, but the legacy_license_based gives a 400 Error and a message of Wrong Pricesheet or malformed Headers.

Its weird as I inspected the same requests from the https://partner.microsoft.com/dashboard while click on pricesheet download, and inspecting the Bearer token it looks very similar to the one I generate from my refresh_token. If I copy the web token, it works with my curl CLI request and I get the legacy_license_based without issues, but that Bearer token is generated by the partner web appId, not with our appId and our refresh_token.

Do you understand? Now my issue is how to get the legacy_license_based pricesheet, as I don't know where to look for this.

Thank you! This was driving me nuts @rarigita Now I'm also stuck on legacy licenses. Ive spent most of my days in the web console to see if there's anything I can grab

GH-KimV avatar Feb 08 '24 20:02 GH-KimV

@rarigita I see you have the Market='ALL' in your second query. Have you tried Market='ES'?

mprentice22153 avatar Feb 09 '24 12:02 mprentice22153