[英]Google sign in for flutter web - Request offline access
I am using google_sign_in_web 0.10.2 https://pub.dev/packages/google_sign_in_web and following the posted example我正在使用 google_sign_in_web 0.10.2 https://pub.dev/packages/google_sign_in_web并遵循发布的示例
Here is some of the relevant code:以下是一些相关代码:
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();
}
I can't find a way to set the access_type
to offline
.我找不到将access_type
设置为offline
的方法。
Is this set by default by the library?这是图书馆默认设置的吗? Else how?不然怎么办?
Thank you.谢谢你。
It looks like this is currently not possible: the source code of this library explicitly mentions it:看起来这目前是不可能的:这个库的源代码明确提到了它:
// 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 https://github.com/flutter/plugins/blob/main/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart#L102
There are also open issues and an open pull request which address this issue:还有一些未解决的问题和解决此问题的公开拉取请求:
https://github.com/flutter/plugins/pull/3356 is a PR aiming to fix this https://github.com/flutter/plugins/pull/3356是一个旨在解决此问题的 PR
https://github.com/flutter/flutter/issues/45847 is an issue describing this problem. https://github.com/flutter/flutter/issues/45847是描述此问题的问题。
https://github.com/flutter/flutter/issues/15796 another issue https://github.com/flutter/flutter/issues/15796另一个问题
But it is coming!但它来了!
It looks like very recently (5 days ago) a new parameter forceCodeForRefreshToken
has been merged into the development version: https://github.com/flutter/plugins/pull/6130 and will be coming into 6.1.0 (not released yet).看起来最近(5天前)一个新参数forceCodeForRefreshToken
已合并到开发版本中: https://github.com/flutter/plugins/pull/6130并将进入 6.1.0(尚未发布) .
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.