我正在使用 code samples 中的代码在应用程序启动时验证用户身份。
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
关于c# - 在应用程序启动时始终提示用户选择帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54100139/