[英]Google sign in for flutter web - exchange authorization code for refresh and access tokens
我正在使用 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();
}
我找不到將授權代碼交換為刷新和訪問令牌的方法
編輯:好的,我找到了訪問令牌:
一旦你有了上面的_currentUser
,你就可以了
final authentication = await _currentUser.authentication;
print(authentication.accessToken);
我仍然需要刷新令牌
好的,我找到了訪問令牌:
一旦你有了上面的_currentUser
,你就可以了
final authentication = await _currentUser.authentication;
print(authentication.accessToken);
GoogleSignIn 在 accessToken 旁邊提供 idToken。
final GoogleSignInAuthentication googleSignInAuthentication =
await googleSignInAccount.authentication;
googleSignInAuthentication.accessToken
googleSignInAuthentication.idToken
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.