无法使用带有AWS Cognito的Blazor WASM获取访问令牌,因为X-Frame-Options设置为DENY [英] Not able to get access token with Blazor WASM with AWS Cognito because X-Frame-Options is set to DENY
问题描述
我将Blazor WebWebAssembly用作前端,将AWS Cognito用作IDP.
I am using Blazor WebWebAssembly as my frontend and AWS Cognito as my IDP.
我可以成功登录到AWS Cognito,但是由于"X-Frame-Options"指令设置为"DENY"错误,因此无法使用以下代码获取访问令牌.
I can successfully login to AWS Cognito, but not able to get the access token with the following code because of the "X-Frame-Options" directive set to "DENY" error.
private async Task WriteTokenToConsole()
{
var tokenResult = await TokenProvider.RequestAccessToken();
if (tokenResult.TryGetToken(out var token))
{
System.Diagnostics.Debug.WriteLine(token.Value);
}
}
但是,如果我将IDP切换到Identity Server 4,则可以毫无问题地获得访问令牌.
Yet, if I switch the IDP to Identity Server 4, I can get the access token no problem.
根据此评论 https://github.com/dotnet/aspnetcore/issues/22651#issuecomment-640565340 ,这是因为Cognito不符合标准吗?
According to this comment https://github.com/dotnet/aspnetcore/issues/22651#issuecomment-640565340 , it is because Cognito is not being standard compliant?
有没有办法解决这个问题?
Is there a way to work around this?
谢谢
推荐答案
I was able to access it via the code on: How do I get the id_token in Blazor WebAssembly after authenticating with OpenId (Cognito)?
此后,我将其抽象为JSRuntime的扩展,以使其更易于在我的代码中重复使用.但这对我来说似乎很好.
I've since abstracted that into an extension to JSRuntime to make it easier to re-use across my code. But it seems to work fine for me.
这篇关于无法使用带有AWS Cognito的Blazor WASM获取访问令牌,因为X-Frame-Options设置为DENY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!