簡體   English   中英

獲取 Google 登錄身份驗證和刷新令牌

[英]Get Google Sign-In Auth & Refresh Token

有沒有辦法從谷歌使用flutter登錄獲取訪問令牌和刷新令牌? 我正在使用:google_sign_in:^3.0.4

您可以創建自己的 google_sign_in 類實現。 最后它只是一個 OAuth 令牌。 這是自定義 google_sign_in 服務的網絡實現: https : //stackoverflow.com/a/69746036/5492496

我很確定您可以使用 Web 視圖對 Android 和 iOS 執行相同的操作。

您可以嘗試通過以下方式獲取它:

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

      _googleSignIn.signIn().then((result){
          result.authentication.then((googleKey){
              print(googleKey.accessToken);
              print(googleKey.idToken);
              print(_googleSignIn.currentUser.displayName);
          }).catchError((err){
            print('inner error');
          });
      }).catchError((err){
          print('error occured');
      });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM