-
Notifications
You must be signed in to change notification settings - Fork 100
Google Sign In Service #495
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8db84be
basic sign in functionality
4647c94
authentication service wip
effccce
moved auth out of widgets
004ab15
move auth service into build state
7b08a6f
auth service, user avatar widget
495490b
added tests
66bc9ab
new line at eof
3b22ad9
removed AuthenticationService interface
ea64d13
update readme
5b924c0
google sign in service test
65ebdab
google scope var
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
authentication service wip
- Loading branch information
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 |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Copyright 2019 The Chromium Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:flutter/foundation.dart' show kReleaseMode; | ||
|
|
||
| /// Service class for interacting with authentication to Cocoon backend. | ||
| /// | ||
| /// This service exists to have a universal location for all the authentication information. | ||
| abstract class AuthenticationService { | ||
| /// Creates a new [AuthenticationService] based on if Flutter app is in production. | ||
| /// | ||
| /// Production uses the Google Sign In service. | ||
| /// Otherwise, use fake data that mimicks being authenticated. | ||
| factory AuthenticationService() { | ||
| if (kReleaseMode) { | ||
|
|
||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| /// Whether or not the application has been logged in to. | ||
| bool get isAuthenticated => _isAuthenticated; | ||
| bool _isAuthenticated = false; | ||
|
|
||
| /// The email of the current user logged in. | ||
| String get email => _email; | ||
| String _email; | ||
|
|
||
| /// The avatar url of the current user logged in. | ||
| String get avatarUrl => _avatarUrl; | ||
| String _avatarUrl; | ||
|
|
||
| /// Initiate the [GoogleSignIn] process. | ||
| Future<bool> signIn(); | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import 'package:app_flutter/service/authentication.dart'; | ||
| import 'package:google_sign_in_all/google_sign_in_all.dart'; | ||
|
|
||
| class GoogleAuthenticationService extends AuthenticationService { | ||
| GoogleAuthenticationService({GoogleSignIn googleSignIn}) | ||
| : _googleSignIn = googleSignIn ?? | ||
| setupGoogleSignIn( | ||
| scopes: <String>[ | ||
| 'https://www.googleapis.com/auth/userinfo.email', | ||
| 'https://www.googleapis.com/auth/userinfo.profile', | ||
| ], | ||
| webClientId: 'github blocks me from putting you here :(', | ||
| ), | ||
| super(); | ||
|
|
||
| GoogleSignIn _googleSignIn; | ||
|
|
||
| AuthCredentials credentials; | ||
|
|
||
| GoogleAccount user; | ||
|
|
||
| @override | ||
| Future<bool> signIn() { | ||
| return null; | ||
| } | ||
| } | ||
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.
Maybe hoist these into private consts
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.
Added