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] Add serverAuthCode attribute to google_sign_in_platform_interface #2634

Merged
merged 4 commits into from
Apr 23, 2020

Conversation

yamarkz
Copy link
Contributor

@yamarkz yamarkz commented Apr 6, 2020

Description

Add attribute serverAuthCode to, the GoogleSignInTokenData class.
serverAuthCode is used in this pr.

Related Issues

#2116

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.

@yamarkz yamarkz changed the title implement server-auth-code-interface [google_sign_in] Add serverAuthCode attribute to google_sign_in_platform_interface Apr 6, 2020
@yamarkz
Copy link
Contributor Author

yamarkz commented Apr 6, 2020

@ditman
I'm not sure how to change package interface. but I want add attribute of serverAuthCode to data class and to merge this pr. Please review

@ditman ditman requested review from ditman, mehmetf and cyanglaz April 6, 2020 18:57
@ditman
Copy link
Member

ditman commented Apr 6, 2020

This one looks good to me. I have added @cyanglaz and @mehmetf as CODEOWNERS of the plugin.

Comment on lines 34 to 35
this.idToken,
this.serverAuthCode,
Copy link
Member

@ditman ditman Apr 6, 2020

Choose a reason for hiding this comment

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

I don't think the User should have information about the serverAuthCode.

Why not limit this to the GoogleSignInTokenData so it can only be retrieved by the getTokens() call?

How do you want people to use this extension to the API? Can you write a quick example/documentation on how to use the new serverAuthCode attribute?

Copy link
Contributor Author

@yamarkz yamarkz Apr 7, 2020

Choose a reason for hiding this comment

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

Thank you for review.

The serverAuthCode is intended to be used on iOS/Android and may also be used on Flutter for web. However, I haven't done any development on the web yet, so I haven't found any use cases on the web.

serverAuthCode usage is as follows.

Behavior of the existing API is the same. However, in order to be able to obtain the serverAuthCode, it is necessary to define the serverClientId on the native code side. here

It is expected that the serverAuthCode can be retrieved with GoogleSignInToken, it is the return value of the authentication function in the GoogleSignInAccount class.

If the serverClientId was not defined, I expect the return value to be "null" when I access the attribute, because getting the serverAuthCode is optional.

In the Flutter App that I am developing, I am using the following

GoogleSignIn _googleSignIn = GoogleSignIn(scopes: <String>['email', etc...])
final account = await _googleSignIn.signIn();
final authentication = await account.authentication;
final serverAuthCode = authentication.serverAuthCode;
// follow serverAuthCode is used in private web service

Is this a reference?

@ditman
Copy link
Member

ditman commented Apr 7, 2020

With this latest change, you'd need to do:

GoogleSignIn _googleSignIn = GoogleSignIn(scopes: <String>['email', etc...])
final account = await _googleSignIn.signIn();
final tokens = await _googleSignIn.getTokens();
final serverAuthCode = tokens.serverAuthCode;
// follow serverAuthCode is used in private web service

Correct?

@yamarkz
Copy link
Contributor Author

yamarkz commented Apr 8, 2020

Yes, that's what I want to do.

In this PR, I will first change the interface. after that, by merging pr, can get the serverAuthCode.

test will fail, so we change the interface first.

@ditman ditman self-requested a review April 8, 2020 23:50
Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

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

Yes, this needs to be merged and published to pub.dev, and then in your other PR, you need to update the pubspec.yaml of the google_sign_in package to depend in this version of google_sign_in_platform_interface (and fix whatever breaks there)

Let's get eyes from @cyanglaz here as well!

@yamarkz
Copy link
Contributor Author

yamarkz commented Apr 20, 2020

Please review. @cyanglaz

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!

@yamarkz
Copy link
Contributor Author

yamarkz commented Apr 23, 2020

Please review. @mehmetf

@ditman ditman added submit queue The Flutter team is in the process of landing this PR. waiting for test harness labels Apr 23, 2020
@ditman
Copy link
Member

ditman commented Apr 23, 2020

I'll merge this as soon as the tree goes green. Thanks for the patience @yamarkz!

@ditman ditman merged commit a931b8f into flutter:master Apr 23, 2020
@ditman
Copy link
Member

ditman commented Apr 23, 2020

Done. I'll update this PR when I publish the package to pub.dev.

EdwinRomelta pushed a commit to EdwinRomelta/plugins that referenced this pull request Jun 11, 2020
…utter#2634)

This change adds the `serverAuthCode` attribute to the `GoogleSignInTokenData` class.

Usage:

```
// Sign in somewhere, then...
final tokens = await _googleSignIn.getTokens();
final serverAuthCode = tokens.serverAuthCode;
// serverAuthCode may be used by your server
```
jorgefspereira pushed a commit to jorgefspereira/plugins_flutter that referenced this pull request Oct 10, 2020
…utter#2634)

This change adds the `serverAuthCode` attribute to the `GoogleSignInTokenData` class.

Usage:

```
// Sign in somewhere, then...
final tokens = await _googleSignIn.getTokens();
final serverAuthCode = tokens.serverAuthCode;
// serverAuthCode may be used by your server
```
FlutterSu pushed a commit to FlutterSu/flutter-plugins that referenced this pull request Nov 20, 2020
…utter#2634)

This change adds the `serverAuthCode` attribute to the `GoogleSignInTokenData` class.

Usage:

```
// Sign in somewhere, then...
final tokens = await _googleSignIn.getTokens();
final serverAuthCode = tokens.serverAuthCode;
// serverAuthCode may be used by your server
```
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes submit queue The Flutter team is in the process of landing this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants