c# - 在应用程序启动时始终提示用户选择帐户

标签 c# youtube-api google-oauth google-api-dotnet-client

我正在使用 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()
});

一切正常,除了我想强制每次都显示“选择帐户”屏幕(现在它只显示第一次,然后用户就会被记住),因为应用程序应该允许不同的用户登录.

看起来我应该设置 promptselect_account 请求参数,但我不知道该怎么做,AuthorizeAsync 方法不接受任何其他参数。

最佳答案

您是对的,目前无法通过简单的方式做到这一点。

我已提交一个错误来修复此问题:https://github.com/googleapis/google-api-dotnet-client/issues/1322

关于c# - 在应用程序启动时始终提示用户选择帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54100139/

相关文章:

c# - 尽管我可以使用 Visual Studio 检查它,但 selenium Web 元素上的文本属性为空

c# - 通过 Windows 窗体发送用户输入

.net - 如何在.Net中使用YoutubeApi v3向YouTube视频添加字幕

javascript - iframe 刷新后 OnStateChange 不起作用

google-api - Google Drive API不够文件权限错误

google-oauth - 实现帐户关联-查询

c# - 在 MVC5 中使用 OWIN 在 IdentityServer 中使用被动身份验证

c# - 如何防止创建处理同一请求的多个后台进程?

c# - 如何使用 C# 在 WPF 中播放 YouTube 视频

go - Go 中对 Google API 的无人值守授权