[英]Get Google Sign-In Auth & Refresh Token
Is there a way to get the access token and refresh token from google sign in with flutter?有没有办法从谷歌使用flutter登录获取访问令牌和刷新令牌? I'm using: google_sign_in: ^3.0.4
我正在使用:google_sign_in:^3.0.4
You can create your own implementation of the google_sign_in class.您可以创建自己的 google_sign_in 类实现。 In the end it's just an OAuth token.
最后它只是一个 OAuth 令牌。 Here's a web implementation of a custom google_sign_in service: https://stackoverflow.com/a/69746036/5492496
这是自定义 google_sign_in 服务的网络实现: https : //stackoverflow.com/a/69746036/5492496
I'm pretty sure you can do the same for Android & iOS using web view.我很确定您可以使用 Web 视图对 Android 和 iOS 执行相同的操作。
You can try getting it this way:您可以尝试通过以下方式获取它:
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.