c# - 强制 google oauth 提示用户选择帐户
问题描述
根据这个,您可以使用prompt
查询字符串告诉 google oauth 您希望用户选择用户帐户。
有人可以告诉我如何在 asp.net 核心中执行此操作 - 如果您AddGoogle
按照以下方式使用代码:
.AddGoogle(GoogleDefaults.AuthenticationScheme, googleOptions =>
{
googleOptions.ClientId = "***";
googleOptions.ClientSecret = "***";
googleOptions.AccessType = "offline";
googleOptions.UserInformationEndpoint = "https://www.googleapis.com/oauth2/v2/userinfo";
googleOptions.ClaimActions.Clear();
googleOptions.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id");
googleOptions.ClaimActions.MapJsonKey(ClaimTypes.Name, "name");
googleOptions.ClaimActions.MapJsonKey(ClaimTypes.GivenName, "given_name");
googleOptions.ClaimActions.MapJsonKey(ClaimTypes.Surname, "family_name");
googleOptions.ClaimActions.MapJsonKey("urn:google:profile", "link");
googleOptions.ClaimActions.MapJsonKey(ClaimTypes.Email, "email");
})
解决方案
我最近也需要这样做。
尝试这个:
googleOptions.AuthorizationEndpoint += "?prompt=consent";
推荐阅读
- python - 你能在 Mac 的 Enthought Canopy 上运行 32 位 python 吗?
- css - 如何根据视图中返回的内容更改颜色?
- python - 使用 mxnet 和 NDarry 训练 CNN 模型
- c# - 'await' 运算符只能在异步方法中使用
- postgresql - 在 JPA 中使用 LATIN1 客户端编码执行 PostgreSQL 函数
- python - 将切片 DataFrame 分配给另一个相同大小的切片 DataFrame 会给出:ValueError, Incompatible indexer with Series
- amazon-web-services - (Amazon Lambda)错误:无法导入模块“处理程序”:/usr/lib64/libstdc++.so.6:未找到版本“GLIBCXX_3.4.20”
- javascript - 如何在 L.geoJSON pointToLayer 中实例化标记
- php - laravel 5.1 中的日期验证
- git - Teamcity git push 错误 - 使用 Maven 发布执行时无法读取用户名