Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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

Closed
wants to merge 6 commits into from

Conversation

dreenot
Copy link

@dreenot dreenot commented Apr 27, 2021

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 before

To 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 update values/bools.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool name="force_code_for_refresh_token">false</bool>
</resources>

And refresh the sign in

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. (Note that unlike the flutter/flutter repo, the flutter/plugins repo does use dart format. See plugin_tool format)
  • I signed the [CLA].
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy].
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • All existing and new tests are passing.

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 the GoogleSignInAuthentication object as that is created by the getTokens call rather than from the data obtained during the initial signIn call (which does contain a serverAuthCode, 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 parameter

Related Issues

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking 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).

fbcouch and others added 6 commits December 20, 2020 14:05
Many changes were made after the PR of commit 0a868b4. I kept the new data when I merged it before this commit, so a few minimal changes were needed to keep it working with master. It's currently getting the serverAuthCode instead of returning null and forceCodeForRefreshToken is now an option.
Many changes were made after the PR of commit 0a868b4. I kept the new data when I merged it before this commit, so a few minimal changes were needed to keep it working with master. It's currently getting the serverAuthCode instead of returning null and forceCodeForRefreshToken is now an option.
@google-cla
Copy link

google-cla bot commented Apr 27, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@stuartmorgan-g
Copy link
Contributor

Given that the original PR has been updated, it doesn't seem like there's a need for this second copy; closing. If you disagree, please leave a comment explaining why and we can revisit.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants