Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[google_sign_in] Fix serverAuthCode getToken on iOS #2788

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/google_sign_in/google_sign_in/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.5.7

* Fix the getToken method used in serverAuthCode on iOS.

## 4.5.6

* Fix deprecated member warning in tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
result(error != nil ? getFlutterError(error) : @{
@"idToken" : authentication.idToken,
@"accessToken" : authentication.accessToken,
@"serverAuthCode" : currentUser.serverAuthCode,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When app is started with an older Google Sign In state the currentUser.serverAuthCode can be nil and this will cause a crash since nil can't be inserted into NSDictionary

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, I had this behaviour also.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey guys, can you please detail how to reproduce this issue? We've tried a few scenarios with this branch, but none caused a crash. @Dahlgren

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It occurs when an existing session with Google Sign In is reused. The serverAuthCode only exists on initial login. If the existing session is flushed (logged out) and a new session is created the serverAuthCode will exist, if applicable.

});
}];
} else if ([call.method isEqualToString:@"signOut"]) {
Expand Down Expand Up @@ -223,8 +224,7 @@ - (void)signIn:(GIDSignIn *)signIn
@"displayName" : user.profile.name ?: [NSNull null],
@"email" : user.profile.email ?: [NSNull null],
@"id" : user.userID ?: [NSNull null],
@"photoUrl" : [photoUrl absoluteString] ?: [NSNull null],
@"serverAuthCode" : user.serverAuthCode ?: [NSNull null]
@"photoUrl" : [photoUrl absoluteString] ?: [NSNull null]
}
error:nil];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/google_sign_in/google_sign_in/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_sign_in
description: Flutter plugin for Google Sign-In, a secure authentication system
for signing in with a Google account on Android and iOS.
homepage: https://github.com/flutter/plugins/tree/master/packages/google_sign_in/google_sign_in
version: 4.5.6
version: 4.5.7

flutter:
plugin:
Expand Down