-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
I am using the plugins/packages/google_sign_in package for authenticating my app. It seems to authenticate fine and I am able to get a profile in the app. The issue I run into is getting a code that will work with my PHP Backend server. The idToken comes back null and the accessToken gives the errors of "id_token must be passed in or set as part of setAccessToken" if I set the Access Token and verifyIdToken. Or if I use the access tokens in the verifyIdToken I get "Wrong number of segments".
I am assuming the token I need is the idToken, but that just comes back as null from the GoogleSignInAuthentication object.
#Code
GoogleSignIn _googleSignIn = new GoogleSignIn(
scopes: [
'email',
'openid',
'profile',
// 'https://www.googleapis.com/auth/contacts.readonly',
],
);
class _MyHomePageState extends State {
AsyncResponse _response = null;
@override
void initState() {
super.initState();
_googleSignIn.onCurrentUserChanged.listen((GoogleSignInAccount account) {
setState(() {
_currentUser = account;
if (account != null) {
account.authentication.then((GoogleSignInAuthentication value) {
setState(() {
//_token = value.accessToken;
print(value.toString());
_token = value.idToken;
_tokenType = 'Google';
});
});
}
});
});
_googleSignIn.signInSilently();
}
Logs
Performing full restart...
Restarted app in 404ms.
I/flutter ( 4098): GoogleSignInAuthentication:{accessToken: , idToken: null}
Flutter Doctor
/usr/local/flutter/bin/flutter --no-color doctor
[✓] Flutter (on Linux, locale en_US.utf8, channel alpha)
• Flutter at /usr/local/flutter
• Framework revision 701d534 (5 days ago), 2017-09-12 14:01:51 -0700
• Engine revision 31d03de
• Tools Dart version 1.25.0-dev.11.0
[✓] Android toolchain - develop for Android devices (Android SDK 25.0.3)
• Android SDK at /home/wafy/Android/Sdk
• Platform android-25, build-tools 25.0.3
• Java binary at: /usr/local/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)
[✓] Android Studio (version 2.3)
• Android Studio at /usr/local/android-studio
• Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)
[✓] IntelliJ IDEA Community Edition (version 2017.2)
• Flutter plugin version 17.0
• Dart plugin version 172.4155.35
[✓] Connected devices
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 5.1.1 (API 22) (emulator)
Process finished with exit code 0