generated from Stacked-Org/package-template
-
Notifications
You must be signed in to change notification settings - Fork 16
Add ability to specify scopes for Google Services when using Google Sign In #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pmmucsd
wants to merge
10
commits into
Stacked-Org:main
Choose a base branch
from
pmmucsd:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ad89996
Add scopes.
pmmucsd f5886b5
Remove space.
pmmucsd 095a101
Refactor for non-web support
pmmucsd c7b3327
Add oAuthAccessToken to FirebaseAuthenticationResult
pmmucsd 3ddc727
Remove oAuthAccessToken getter from class, just pass it back with Fir…
5ce8909
Update pubspec.yaml
pmmucsd 12f1653
Update pubspec.yaml
pmmucsd a59e640
Update pubspec.yaml
pmmucsd 1ce477e
Update pubspec.yaml
pmmucsd 00bb914
Update pubspec.yaml
pmmucsd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ class FirebaseAuthenticationService { | |
| final Logger? log; | ||
|
|
||
| final firebaseAuth = FirebaseAuth.instance; | ||
| final GoogleSignIn _googleSignIn = GoogleSignIn(); | ||
| GoogleSignIn? _googleSignIn; | ||
|
|
||
| FirebaseAuthenticationService({ | ||
| @Deprecated( | ||
|
|
@@ -35,7 +35,7 @@ class FirebaseAuthenticationService { | |
| Future<UserCredential> _signInWithCredential( | ||
| AuthCredential credential, | ||
| ) async { | ||
| return firebaseAuth.signInWithCredential(credential); | ||
| return await firebaseAuth.signInWithCredential(credential); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do we need to await here if the calling function should be awaiting the future? |
||
| } | ||
|
|
||
| /// Returns the current logged in Firebase User | ||
|
|
@@ -77,7 +77,7 @@ class FirebaseAuthenticationService { | |
| /// - iOS | ||
| /// - Web | ||
| Future<FirebaseAuthenticationResult> signInWithGoogle( | ||
| {String? webLoginHint}) async { | ||
| {String? webLoginHint, List<String>? scopes}) async { | ||
| try { | ||
| UserCredential userCredential; | ||
|
|
||
|
|
@@ -87,7 +87,7 @@ class FirebaseAuthenticationService { | |
| GoogleAuthProvider googleProvider = GoogleAuthProvider(); | ||
| googleProvider.setCustomParameters( | ||
| {'login_hint': webLoginHint ?? '[email protected]'}); | ||
|
|
||
| (scopes ?? []).forEach(googleProvider.addScope); | ||
| userCredential = await FirebaseAuth.instance.signInWithPopup( | ||
| googleProvider, | ||
| ); | ||
|
|
@@ -96,8 +96,9 @@ class FirebaseAuthenticationService { | |
| /// On native platforms, a 3rd party library, like GoogleSignIn, is | ||
| /// required to trigger the authentication flow. | ||
| else { | ||
| _googleSignIn = GoogleSignIn(scopes: scopes ?? []); | ||
| final GoogleSignInAccount? googleSignInAccount = | ||
| await _googleSignIn.signIn(); | ||
| await _googleSignIn!.signIn(); | ||
| if (googleSignInAccount == null) { | ||
| log?.i('Process is canceled by the user'); | ||
| return FirebaseAuthenticationResult.error( | ||
|
|
@@ -125,6 +126,7 @@ class FirebaseAuthenticationService { | |
| return FirebaseAuthenticationResult( | ||
| user: userCredential.user, | ||
| additionalUserInfo: userCredential.additionalUserInfo, | ||
| oAuthAccessToken: userCredential.credential?.accessToken, | ||
| ); | ||
| } on FirebaseAuthException catch (e) { | ||
| log?.e(e); | ||
|
|
@@ -510,7 +512,7 @@ class FirebaseAuthenticationService { | |
| try { | ||
| _clearPendingData(); | ||
| await firebaseAuth.signOut(); | ||
| await _googleSignIn.signOut(); | ||
| await _googleSignIn?.signOut(); | ||
| await FacebookAuth.instance.logOut(); | ||
| } catch (e) { | ||
| log?.e('Could not sign out of social account. $e'); | ||
|
|
@@ -597,17 +599,20 @@ class FirebaseAuthenticationResult { | |
|
|
||
| /// Firebase additional user information | ||
| final AdditionalUserInfo? additionalUserInfo; | ||
| final String? oAuthAccessToken; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice addition here. |
||
|
|
||
| /// Contains the error message for the request | ||
| final String? errorMessage; | ||
| final String? exceptionCode; | ||
|
|
||
| FirebaseAuthenticationResult({this.user, this.additionalUserInfo}) | ||
| FirebaseAuthenticationResult( | ||
| {this.user, this.additionalUserInfo, this.oAuthAccessToken}) | ||
| : errorMessage = null, | ||
| exceptionCode = null; | ||
|
|
||
| FirebaseAuthenticationResult.error({this.errorMessage, this.exceptionCode}) | ||
| : user = null, | ||
| oAuthAccessToken = null, | ||
| additionalUserInfo = null; | ||
|
|
||
| /// Returns true if the response has an error associated with it | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the benefit of going to a nullable
GoogleSignInobject and not usinglate?