繁体   English   中英

Google 登录 flutter web - 请求离线访问

[英]Google sign in for flutter web - Request offline access

我正在使用 google_sign_in_web 0.10.2 https://pub.dev/packages/google_sign_in_web并遵循发布的示例

以下是一些相关代码:

GoogleSignIn _googleSignIn = GoogleSignIn(
  scopes: [
    'email',
    'https://www.googleapis.com/auth/contacts.readonly',
  ],
);


  @override
  void initState() {
    super.initState();
            _googleSignIn.onCurrentUserChanged.listen((GoogleSignInAccount? account) {
          setState(() {
            _currentUser = account;
          });
          if (_currentUser != null) {
            _handleGetContact(_currentUser!);
          }
        });
        _googleSignIn.signInSilently();
      }

我找不到将access_type设置为offline的方法。

这是图书馆默认设置的吗? 不然怎么办?

谢谢你。

看起来这目前是不可能的:这个库的源代码明确提到了它:

    // On Android, there isn't an API for refreshing the idToken, so re-use
    // the one we obtained on login.
    response.idToken ??= _idToken;

https://github.com/flutter/plugins/blob/main/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart#L102

还有一些未解决的问题和解决此问题的公开拉取请求:

但它来了!

看起来最近(5天前)一个新参数forceCodeForRefreshToken已合并到开发版本中: https://github.com/flutter/plugins/pull/6130并将进入 6.1.0(尚未发布) .

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM