【发布时间】:2021-03-26 18:16:37
【问题描述】:
在我的 Blazor WASM 应用程序中,我使用 OIDC 身份验证登录 Google Drive,如下所述:
Secure an ASP.NET Core Blazor WebAssembly standalone app with the Authentication library
Google Auth error getting access token in Blazor
Cannot log in or get access token with Google Authorization on Blazor WASM Standalone app
但我不想用
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
@if (!context.User.Identity.IsAuthenticated)
{
<RedirectToLogin />
}
</NotAuthorized>
</AuthorizeRouteView>
因为我不想限制用户访问我的 Blazor 页面。
最重要的是:我不希望用户在未登录时看到“正在授权...”消息几秒钟 - 登录是可选的。
如果用户决定使用 Google Drive,我只需要 Google OAuth 登录,这样我就可以获得访问令牌。
如何仅使用 OIDC 身份验证来获取 Google Drive 的访问令牌?
如果这不可行,我可以使用 C# 登录到 Google,就像这里在 JavaScript 中看到的那样?
【问题讨论】:
标签: google-oauth blazor openid-connect