簡體   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