c# - 始终提示用户在应用程序启动时选择一个帐户
问题描述
我正在使用代码示例中的代码在应用程序启动时对用户进行身份验证。
UserCredential credential;
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
{
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] { YouTubeService.Scope.Youtube },
"user",
CancellationToken.None,
new FileDataStore(this.GetType().ToString())
);
}
var youtubeService = new YouTubeService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = this.GetType().ToString()
});
一切正常,除了我想每次都强制显示“选择帐户”屏幕(现在它只显示第一次,然后记住用户),因为应用程序应该允许不同的用户登录。
看起来我应该将prompt
请求参数设置为 select_account
,但我不知道我应该怎么做,AuthorizeAsync
方法不接受任何额外的参数。
解决方案
您是对的,目前无法以简单的方式做到这一点。
我已经提交了一个错误来解决这个问题:https ://github.com/googleapis/google-api-dotnet-client/issues/1322
推荐阅读
- json.net - Why does validation fail in code, but work in Newtonsoft web validator?
- r - R system2成功后退出失败
- android - Mapbox-gl 在 android 模拟器(离子电容器)上崩溃
- linux - mremap 返回大小,但应该返回一个有效的指针
- java - 将 String 中的 Headers 数据转换为 Map
> - flutter - 颤振:堆栈和墨水覆盖
- css - 使用 flex 根据窗口大小将内容显示为行或列
- javascript - Cube.js - 无法加入 2 个或更多表,但不断收到“找不到要加入的加入路径”错误
- ios - 带有 WebView 的 iOS 中的 URL 方案
- reactjs - 成功消息显示两次反应JS