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

[google_sign_in] Add ability to return serverAuthCode #2116

Merged
merged 40 commits into from
May 19, 2020

Conversation

yamarkz
Copy link
Contributor

@yamarkz yamarkz commented Sep 27, 2019

Description

Supports SERVER_CLIENT_ID(iOS) and default_web_client_id(Android) parameter so that serverAuthCode can be returned.

Related Issues

flutter/flutter#16613
#879
#1704
#1475

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • 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 signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

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.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@yamarkz
Copy link
Contributor Author

yamarkz commented Sep 27, 2019

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

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

Thank you for providing this. I left some comments. Could you also update the pubspec?

@@ -1,3 +1,7 @@
## 4.0.10
Copy link
Contributor

Choose a reason for hiding this comment

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

This patch actually updated the response of the public API so it should be 4.1.0

@@ -239,6 +239,7 @@ public void init(
"default_web_client_id", "string", registrar.context().getPackageName());
if (clientIdIdentifier != 0) {
optionsBuilder.requestIdToken(registrar.context().getString(clientIdIdentifier));
optionsBuilder.requestServerAuthCode(registrar.context().getString(clientIdIdentifier));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the serverClientId always static? We might want to have it be able to set through code as well. Same in iOS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cyanglaz
Thank you for review and comment. I'm going to modify them.
About here, In my opinion I think serverClientId is static define, because it is not dynamic value.
but if you have idea or opinion, i give priority to them. please tell me :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

returning serverAuthCode is using my flutter app. so I'm positive about support this modify.

Copy link
Contributor Author

@yamarkz yamarkz Nov 8, 2019

Choose a reason for hiding this comment

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

and return null if SERVER_CLIENT_ID value is null.

@@ -91,6 +97,10 @@ class GoogleSignInAccount implements GoogleIdentity {
if (response['idToken'] == null) {
response['idToken'] = _idToken;
}

if (response['serverAuthCode'] == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nits: response['serverAuthCode'] ??=_serverAuthCode;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's cool

@5hanth
Copy link

5hanth commented Nov 7, 2019

once this is available, we can pass in custom serverClientId ?

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

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

LGTM to the approach. Could you add tests for this change? Also, please update the pubspec with a new version.

@yamarkz
Copy link
Contributor Author

yamarkz commented Apr 24, 2020

Please review. @ditman, @cyanglaz, @mehmetf

@@ -1,3 +1,7 @@
## 4.5.0

* Add support for getting `serverAuthCode`
Copy link
Contributor

Choose a reason for hiding this comment

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

nits:

Suggested change
* Add support for getting `serverAuthCode`
* Add support for getting `serverAuthCode`.

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="default_web_client_id">YOUR_WEB_CLIENT_ID</string>
</resources>
Copy link
Contributor

Choose a reason for hiding this comment

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

new line EOF

@@ -240,6 +240,7 @@ public void init(
"default_web_client_id", "string", registrar.context().getPackageName());
if (clientIdIdentifier != 0) {
optionsBuilder.requestIdToken(registrar.context().getString(clientIdIdentifier));
optionsBuilder.requestServerAuthCode(registrar.context().getString(clientIdIdentifier));
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems only gets context from registrar. With v2 embedding, we would need to get the context from the plugin binding.

@yamarkz
Copy link
Contributor Author

yamarkz commented Apr 30, 2020

I've modified review point. @cyanglaz

@ditman ditman requested a review from cyanglaz April 30, 2020 18:21
@Dreamersoul
Copy link

hello, any update when this will get merged?

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

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

LGTM

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

Successfully merging this pull request may close these issues.