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

Conversation

@emerssso
Copy link
Contributor

Description

Adds two new methods, hasGrantedScope and requestScope, to the GoogleSginInPlatform class and the method channel implementation.

I have a second branch queued up for the implementations, but my understanding of the federated plugin design is that this has to be merged and pushed to pub first?

Related Issues

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.

@emerssso
Copy link
Contributor Author

Re-created PR since I messed up a rebase. Sorry about that.

@mehmetf mehmetf requested a review from ditman February 27, 2020 00:34
@mehmetf
Copy link
Contributor

mehmetf commented Feb 27, 2020

@ditman This is an internal request. I am not sure how to review it since I am used to reviewing end to end implementations of plugin code. This is just a change on interface. Could you please advise?

@ditman ditman requested a review from cyanglaz February 27, 2020 01:48
@ditman
Copy link
Member

ditman commented Feb 27, 2020

@mehmetf This looks good, the only thing "missing" (which I'm assuming is on a separate PR for the google_sign_in package) are the changes to the native code to implement the new MethodChannel messages (hasGrantedScope and requestScope ), in case they're new?

My only comment may be that this methods seem to be called hasPermissions and requestPermissions on the android side, and maybe you want to keep that name on the method channel call as well.

(This also seems implementable on web through the hasGrantedScopes and grant methods?)

@emerssso
Copy link
Contributor Author

@ditman, the implementations for Android/iOS/web are in #2562. I split them out since it seemed like the build failed due to the 1.1.0 not being in pub?

Happy to swap out the method names, I went with 'scope' since that seemed to be what was used in the plugin (i.e. constructor).

@ditman
Copy link
Member

ditman commented Feb 27, 2020

@emerssso re: naming: whatever makes more sense when using the plugin is fine, no need to rename.

Re: splitting the PR: yes, it is needed to publish the packages in the correct order. Thanks for the link!

@emerssso
Copy link
Contributor Author

Suggested offline that this would be improved by allowing multiple new scopes to be requested at once so the user doesn't potentially have to be prompted multiple times in that case.

I'll work on that and add the changes needed to each PR.

@emerssso
Copy link
Contributor Author

Updated both methods to allow the caller to pass multiple scopes. The flow I'm envisioning is

final missingScopes = await googleSignIn.listMissingScopes(newScopes);
// handle missing scopes, i.e. showing justifications,etc

final granted = await googleSignIn.requestScopes(missingScopes);
if(granted) doStuff();

Still working on updating the implementations; wanted to get feedback on this change to the API.

@ditman
Copy link
Member

ditman commented Feb 28, 2020

wanted to get feedback on this change to the API.

@emerssso Can we do the "missingScopes" check internally, so the user doesn't have to care about the ones that are already granted? I think that'd make the API slightly easier to use.

@emerssso
Copy link
Contributor Author

Can we do the "missingScopes" check internally, so the user doesn't have to care about the ones that are already granted? I think that'd make the API slightly easier to use.

That would meet my immediate needs. I've seen uses of the "missingScopes" flow, but it's not necessary.

@ditman
Copy link
Member

ditman commented Feb 28, 2020

@emerssso just trying to keep the API surface of the plugin as small as possible (and as close as possible to the Google Sign In API itself; the closest thing I've seen there is getGrantedScopes, but nothing similar to getMissingScopes)

@emerssso
Copy link
Contributor Author

@ditman Makes sense. I'll consolidate them to just requestScopes.

@ditman
Copy link
Member

ditman commented Mar 3, 2020

This makes sense to me, but please seek approval from @cyanglaz since this affects all platforms, not only web!

(PS: Thanks for the web implementation!)

}

/// Requests the user grants additional Oauth [scopes].
Future<bool> requestScopes(List<String> scopes) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

what can be the values of the scopes? Maybe we should either make an enum or have some concrete list of what the values can be.

Copy link
Member

@ditman ditman Mar 4, 2020

Choose a reason for hiding this comment

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

@cyanglaz There's a TON of auth scopes, here's the list: https://developers.google.com/identity/protocols/googlescopes (each API that you want to use has its own set of scopes). In Java for example, each API may provide its set of scopes, and not the core plugin.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can add this link to the dartdoc?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that's a good point! It can probably be added to the README.md.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a link in the dartdoc. Looks like this is already mentioned in the README.md here.

@emerssso emerssso requested a review from cyanglaz March 5, 2020 00:33
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

@cyanglaz cyanglaz merged commit 3337ccf into flutter:master Mar 11, 2020
EdwinRomelta pushed a commit to EdwinRomelta/plugins that referenced this pull request Jun 11, 2020
FlutterSu pushed a commit to FlutterSu/flutter-plugins that referenced this pull request Nov 20, 2020
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.

5 participants