如何解决Blazor Server中的压实解析失败错误?
对于添加了与此问题相关的另一个问题,我深表歉意。我已经仔细地审查了所有Microsoft文档,以及堆栈Overflow和Github上的问题,但仍然无法解决此问题。
我正在创建一个使用Azure AD和Microsoft Graph对用户进行身份验证并授权用户的Blazor Server应用程序(.NET 5)。在我的本地机器上测试时,我已经能够完美地实现。一旦在Azure上部署,该应用将对用户进行身份验证,但是当我尝试访问需要授权的页面时,我收到了以下错误:
错误:状态代码:未经授权 Microsoft.graph.ServiceException:代码:InvalideUthenticationToken 消息:compacttoken解析因错误代码而失败:80049217
我使用Microsoft Identity平台创建了使用默认授权的应用程序,并且几乎没有更改为'startup.cs'文件。基于我能够收集的信息,当调用图形API时,HTTP标头中提供了无效的访问令牌,似乎会产生此错误。我尝试了无数次根据其他人使用但无用的解决方案来解决此问题。
我无法提供指向源代码的链接,因为这是一个专有的应用程序,但是如果需要,我可以提供一些小型通用示例。
我希望有一些大型开发人员可以慷慨地为我提供一些面包屑。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果使用生成的访问令牌以错误的方式调用API ,则可能会发生此错误。
我试图通过邮递员来重现相同的错误:
error “代码:invalideathentication tokentoken message:compacttoken错误代码失败:80049217“ 通常是由于以下原因之一而发生的:
如果您包括带有 quot quotes 的额外字符的令牌,则空格,缺失字符等等,发生此错误。
要解决错误 ,请确保通过检查上述内容准确地通过令牌。
请检查代码您用代币调用图形API。
通过 space 在传递
令牌参数
(“ bearer”+space+token)时。 /p>请检查代码参数中是否有任何 typos 。
如果您使用 Postman 来调用Graph API,则只需在其前面输入令牌而不是字符串“ Bearer”。
请检查端点您正在用来生成访问令牌。
如果您使用的是 v1.0端点,则使用
资源
参数。如果您使用的是 v2.0端点,则使用
范围
参数。有关更多详细信息,请请参阅下面的链接:
https ://github.com/onedrive/onedrive-api-docs/issues/785
Azure Active Directory -InvalideUthenticationToken- compacttoken解析失败,错误代码:-2147184105-堆栈溢出
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:
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