This repository was archived by the owner on Feb 22, 2023. It is now read-only.
[google_sign_in] Fix issue obtaining serverAuthCode on Android and add forceCodeForRefreshToken parameter // Update #3829
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a follow to #3356. It merges into the master keeping the master's preferences. It has been a long time since it was requested and the code has significantly changed. A few changes were needed to make it work with the current master. Therefore, I'm just updating #3356. The Pre-launch Checklist belongs to this PR, but the following info is a reference.
tl;dr
serverAuthCode
is returning the right value, not null.forceCodeForRefreshToken
is now an option, it wasn't available beforeTo test it, sign in and get the
serverAuthCode
final user = await googleSignIn.signIn();
final googleAuth = await user.authentication;
final serverAuthCode = googleAuth.serverAuthCode
To test
forceCodeForRefreshToken
updatevalues/bools.xml
And refresh the sign in
Pre-launch Checklist
dart format
. See plugin_tool format)[shared_preferences]
///
).The description below comes from the previous #3356
Description
This is a follow up to #2116 to fix the following issues:
serverAuthCode
is always null on Android because it is not passed to theGoogleSignInAuthentication
object as that is created by thegetTokens
call rather than from the data obtained during the initialsignIn
call (which does contain aserverAuthCode
, it's just not accessible anywhere that I can tell)A refresh token is only given to the server on the first sign in without the ability to set the
forceCodeForRefreshToken
parameterRelated Issues
google_sign_in - Using custom back-end id to get token flutter#17813
How to get a refresh token in google_sign_in plugin? flutter#14245
Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?
Festivus Note
As the season of Festivus is upon us, I do have a grievance to air from the last time I submitted a PR related to this plugin. I was told on #879 that my pull request to add the serverAuthCode (which worked on android, as a side note) would not be accepted without E2E tests using a test harness that wasn't even ready yet. You can imagine my surprise when #2116 was merged a few months later without them (no disrespect to the author of that PR, they did what was asked of them).