【问题标题】:Flutter google_sign_in "Choose Account" does not list Youtube brand accounts?Flutter google_sign_in“选择账号”不列出Youtube品牌账号?
【发布时间】:2021-06-07 05:05:47
【问题描述】:

我目前正在使用https://pub.dev/packages/google_sign_in

到目前为止它工作正常,但在 Google 登录弹出窗口中,我在“选择帐户”处看不到我的 Youtube 品牌帐户,因此,Youtube 数据 API 无法正确识别带有参数“我的”的 API 调用=true",因为如果我选择我的 Google 帐户,它与 Youtube 帐户没有任何关联。

在 Youtube Data API 的文档中,如果我在那里“立即尝试”,Google SignIn 会在我选择我的 Google 帐户后列出我的 Youtube 品牌帐户。

使用过的包:

Flutter 2.0.1
Dart 2.12.0
google_sign_in: 5.0.0

示例代码(使用 firebase 和 API Explorer 的权限已设置并有效):

final GoogleSignIn _googleSignIn = GoogleSignIn(
  signInOption: SignInOption.standard, // not necessary
  scopes: <String>['https://www.googleapis.com/auth/youtube']);
...
this._googleSignIn.onCurrentUserChanged.listen((GoogleSignInAccount account) {}
...
this._googleSignIn.signIn();
...

因此,Youtube 数据 API 调用为我的 Google 帐户返回了一个空结果(但调用有效):

http.get(
    Uri.parse(
 'https://www.googleapis.com/youtube/v3/channels?part=id,snippet,contentDetails&mine=true'),
 headers: await currentGoogleUser.authHeaders);

有什么帮助,所以我在 GoogleSignIn 过程中得到了选择 Youtube 品牌帐户的屏幕?

另请参阅https://github.com/flutter/flutter/issues/77694

【问题讨论】:

  • 不,正如您在最后一条评论中看到的那样,google 和 youtube 帐户之间没有关联,所以我猜他也无法选择他的 youtube 品牌帐户。

标签: api flutter google-api google-signin


【解决方案1】:

尝试从以下位置删除

scopes: <String>['https://www.googleapis.com/auth/youtube']);

这是我的猜测。

【讨论】:

  • 我不知道你想要实现什么不同,但是没有它不起作用
  • 好吧,我认为在代码中包含 不会编译。为什么会在那里?但无论如何......我敢打赌这个问题与这行代码有关——由于一些格式问题,范围没有被成功应用。
猜你喜欢
  • 2022-08-23
  • 2019-07-25
  • 2018-07-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-29
  • 1970-01-01
相关资源
最近更新 更多