0

I apologize in advance for adding yet another question related to this issue. I've carefully reviewed all of the Microsoft docs, as well as questions on Stack Overflow and GitHub, but still cannot resolve this issue.

I'm creating a Blazor Server application (.NET 5) that authenticates and authorizes users using Azure AD and Microsoft Graph. I've been able to implement this perfectly when testing on my local machine. Once deployed on Azure, the app will authenticate the user, but when I attempt to access a page that requires authorization I received the following error:

Error: Status Code: Unauthorized Microsoft.Graph.ServiceException: Code: InvalidAuthenticationToken Message: CompactToken parsing failed with error code : 80049217

I created the app with the default authorization using Microsoft Identity Platform and have changed little to the 'Startup.cs' file. Based on the information I've been able to gather it seems like this error is produced when an invalid Access Token is provided in the HTTP header when calling the Graph API. I've tried countless times to fix this issue according to various solutions others have used but without avail.

I'm unable to provide a link to the source code because this is a proprietary app, however I can provide some small generic samples if needed.

I'm hoping that there's some fellow Blazor developers who might be able to graciously provide some breadcrumbs for me to follow on this.

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
saganaga
  • 63
  • 7

1 Answers1

0

If you use the generated access token to call the API in a wrong way, this error may occur.

I tried to reproduce the same error via Postman like below:

enter image description here

The error "Code: InvalidAuthenticationToken Message: CompactToken parsing failed with error code : 80049217" usually occurs due to one of the below reasons:

  • If you included the token with extra characters like quotes, spaces, missing characters etc., this error occurs.

  • To resolve the error, make sure to pass the token accurately by checking the above.

  • Please check the code you are using to call the Graph API with token.

  • Make sure to give the space between Bearer and token while passing the token parameter (“Bearer”+space+token ).

  • Please check whether there are any typos in the code parameters.

  • If you are using Postman to call Graph API, just enter the token not the string "Bearer " in front of it.

  • Please check the endpoint you are using to generate the access token.

  • If you are using V1.0 endpoint, then use resource parameter. If you are using V2.0 endpoint, then use scope parameter.

For more in detail, please refer below links:

https://github.com/OneDrive/onedrive-api-docs/issues/785

azure active directory - InvalidAuthenticationToken - CompactToken parsing failed with error code: -2147184105 - Stack Overflow

Sridevi
  • 10,599
  • 1
  • 4
  • 17