Skip to content

Commit 51c003c

Browse files
Merge pull request #2 from funwithflutter/oauth-plugin
Oauth plugin
2 parents 6d7b74a + 0bdee1e commit 51c003c

25 files changed

+2525
-624
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 0.2.0
2+
3+
- BREAKING: change in Apple authentication method
4+
- BREAKING: change in the way buttons are customized through `AuthConfig`
5+
- feat: additional sign-in providers added - Github, Twitter and Apple (iOS, Android and Web)
6+
- docs: various documentation updates
7+
18
# 0.1.3
29

310
- feat: add functionality to customize notification messages

README.md

Lines changed: 59 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ Pre-lit Firebase authentication. It provides a set of convenient utilities and w
1010
## Features
1111

1212
- **Multiple platform support**
13-
- Works on mobile and web. No changes needed
13+
- Works on mobile (Android/iOS) and web. No changes needed
1414
- Windows, macOS and Linux to be added in the future
1515
- **Multiple authentication providers**
16-
- Package supported: Google and Apple
17-
- Please see [Authentication Providers](#authentication-providers) for other sign-in providers
16+
- Package supported: Google, Apple, Twitter and Github
17+
- Please see [Authentication Providers](#authentication-providers) for additional information
1818
- **Services and state managed for you**
1919
- Easily interact with Firebase from anywhere in your app
2020
- Monitor the auth state and react to changes
2121
- **Error handling and error messages**
2222
- Built in error handling that will display friendly in-app error messages
23-
- Error/Success dialogs will be customizable in future versions
23+
- Error/Success dialogs can be customized
2424
- **Highly customizable**
25-
- Either use the standard sign-in widgets, or easily create your own.
25+
- Either use the standard sign-in widgets, or create your own.
2626

2727
## Getting started
2828

@@ -122,16 +122,10 @@ class MyApp extends StatelessWidget {
122122
authProviders: AuthProviders(
123123
emailAndPassword: true, // enabled by default
124124
google: true,
125+
apple: true,
126+
twitter: true,
127+
github: true,
125128
anonymous: true,
126-
apple: AppleAuthProvider(
127-
// required for web-based authentication flows (Android)
128-
webAuthenticationOptions: WebAuthenticationOptions(
129-
clientId: 'com.aboutyou.dart_packages.sign_in_with_apple.example', // example clientId
130-
redirectUri: Uri.parse(
131-
'https://flutter-sign-in-with-apple-example.glitch.me/callbacks/sign_in_with_apple', // example redirectUri
132-
),
133-
),
134-
),
135129
),
136130
child: MaterialApp(
137131
title: 'Material App',
@@ -242,15 +236,51 @@ context.getSignedInUser()
242236
## Authentication Providers
243237
For the time being, Lit Firebase auth will only directly provide Google and Apple sign in.
244238

245-
**NOTE:** Apple requires Apple sign in to be a sign-in option if any other third-party sign-in option is used.
239+
**NOTE:** Apple requires Apple sign in to be enalbed if any other third-party sign-in option is used.
240+
241+
The supported third-party providers are:
242+
* Google
243+
* Apple
244+
* Github
245+
* Twitter
246+
247+
These need to be enabled in the `LitAuthInit` widget.
248+
```dart
249+
LitAuthInit(
250+
// specify which auth providers to enable
251+
authProviders: AuthProviders(
252+
emailAndPassword: true, // enabled by default
253+
google: true,
254+
apple: true,
255+
twitter: true,
256+
github: true,
257+
anonymous: true,
258+
),
259+
child: MaterialApp(
260+
title: 'Material App',
261+
home: Home(),
262+
),
263+
);
264+
```
265+
266+
To initiate authentication with one of these providers, call the relevant method. For example:
246267

247-
Other identity providers (Facebook, Github, etc.) will need to be implemented seperately. After successful third party sign in, you can sign in to Firebase by making use of the `signInWithCredential` method available on `BuildContext`.
268+
```dart
269+
FlatButton(
270+
onPressed: () {
271+
context.signInWithGithub();
272+
},
273+
child: Text('Github Sign In'),
274+
),
275+
```
276+
277+
Other identity providers (for example, Facebook) will need to be implemented seperately. After successful third party sign in you can sign in to Firebase by making use of the `signInWithCredential` method available on `BuildContext`.
248278

249279
For example:
250280

251281
```dart
252282
Widget build(BuildContext context) {
253-
AuthCredential credential = // get credential for identity provider (Facebook, Github, etc.)
283+
AuthCredential credential = // get credential for identity provider (Facebook, etc.)
254284
context.signInWithCredential(credential);
255285
}
256286
```
@@ -276,18 +306,18 @@ return LitAuth(
276306
```dart
277307
return LitAuth(
278308
config: AuthConfig(
279-
googleButton: ButtonConfig(
280-
type: ButtonType.raised(),
281-
themeData: ButtonThemeData(
282-
buttonColor: Colors.red,
283-
),
284-
child: Text('My styled Google Sign-in'),
309+
signInButton: ButtonConfig.raised(
310+
themedata: ButtonThemeData(buttonColor: Colors.red),
311+
child: Text('Sign in with Email'),
285312
),
313+
googleButton: GoogleButtonConfig.light(),
314+
appleButton: AppleButtonConfig.dark(),
286315
),
287-
);
288-
316+
),
289317
```
290318

319+
There are a number of different button customizations that you can do.
320+
291321
### Notifications
292322
Notifications are rendered using the [flushbar](https://pub.dev/packages/flushbar) package.
293323

@@ -307,6 +337,7 @@ There are many attributes that can be altered to create the desired notification
307337
For further customization you can directly make use of the Lit Firebase components to build a completely custom sign-in widget.
308338

309339
Instead of using the standard `AuthConfig`, set it to custom and provide your custom sign-in widget:
340+
310341
```dart
311342
return LitAuth.custom(
312343
child: YourCustomSignInWidget(),
@@ -375,14 +406,14 @@ class YourCustomSignInWidget extends StatelessWidget {
375406
| | State | |
376407
| ----------------- | ---------- | ---------------------------------------------------------------- |
377408
| Platforms || Support more platforms (Windows, macOS, Linux) |
378-
| Auth providers || Support more authentication providers (Github, Facebook) |
409+
| Auth providers || Support more authentication providers (Facebook, Microsoft) |
379410
| Cupertino || Cupertino look and feel |
380411
| Password reset || Add services and UI to reset password/email |
381412
| Email confirmation|| Add UI to notify users they need to confirm their email address |
382413
| Support UI || Assist users who cannot authenticate with support links |
383-
| Custom dialogs | | Add support to customize dialog messages |
414+
| Custom dialogs | ✔️ | Add support to customize dialog messages |
384415
| Adaptive layouts || Adaptive layouts to support multiple screen sizes |
385-
| Customization | | Even more, or easier, customization |
416+
| Customization | ✔️ | Even more, or easier, customization |
386417
| Testing || Add testing |
387418

388419
## Dart Versions

example/lib/main.dart

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ class MyApp extends StatelessWidget {
1111
authProviders: AuthProviders(
1212
emailAndPassword: true, // enabled by default
1313
google: true,
14+
apple: true,
1415
anonymous: true,
16+
github: true,
17+
twitter: true,
1518
// apple: AppleAuthProvider(
1619
// // required for web-based authentication flows
1720
// webAuthenticationOptions: WebAuthenticationOptions(
@@ -24,10 +27,15 @@ class MyApp extends StatelessWidget {
2427
),
2528
child: MaterialApp(
2629
title: 'Material App',
30+
themeMode: ThemeMode.light,
31+
darkTheme: ThemeData.dark(),
2732
theme: ThemeData(
28-
primaryColor: Colors.blueGrey,
29-
accentColor: Colors.pink[400],
3033
visualDensity: VisualDensity.adaptivePlatformDensity,
34+
buttonTheme: ButtonThemeData(
35+
buttonColor: Colors.white,
36+
textTheme: ButtonTextTheme.primary,
37+
height: 40,
38+
),
3139
),
3240
home: SplashScreen(),
3341
),
@@ -56,6 +64,8 @@ class SplashScreen extends StatelessWidget {
5664
textAlign: TextAlign.center,
5765
style: Theme.of(context).textTheme.headline4,
5866
),
67+
googleButton: GoogleButtonConfig.light(),
68+
appleButton: AppleButtonConfig.dark(),
5969
),
6070
),
6171

@@ -136,10 +146,16 @@ class CustomSignInWidget extends StatelessWidget {
136146
},
137147
child: Text('Anony Sign In'),
138148
),
139-
SignInWithAppleButton(
149+
// SignInWithAppleButton(
150+
// onPressed: () {
151+
// context.signInWithApple();
152+
// },
153+
// ),
154+
FlatButton(
140155
onPressed: () {
141-
context.signInWithApple();
156+
context.signInWithGithub();
142157
},
158+
child: Text('Github Sign In'),
143159
),
144160
],
145161
),

example/pubspec.lock

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,27 @@ packages:
7878
url: "https://pub.dartlang.org"
7979
source: hosted
8080
version: "0.16.1"
81+
firebase_auth_oauth:
82+
dependency: transitive
83+
description:
84+
name: firebase_auth_oauth
85+
url: "https://pub.dartlang.org"
86+
source: hosted
87+
version: "0.1.1+1"
88+
firebase_auth_oauth_platform_interface:
89+
dependency: transitive
90+
description:
91+
name: firebase_auth_oauth_platform_interface
92+
url: "https://pub.dartlang.org"
93+
source: hosted
94+
version: "0.1.0+6"
95+
firebase_auth_oauth_web:
96+
dependency: transitive
97+
description:
98+
name: firebase_auth_oauth_web
99+
url: "https://pub.dartlang.org"
100+
source: hosted
101+
version: "0.1.0+7"
81102
firebase_auth_platform_interface:
82103
dependency: transitive
83104
description:
@@ -125,20 +146,13 @@ packages:
125146
description: flutter
126147
source: sdk
127148
version: "0.0.0"
128-
flutter_auth_buttons:
129-
dependency: transitive
130-
description:
131-
name: flutter_auth_buttons
132-
url: "https://pub.dartlang.org"
133-
source: hosted
134-
version: "0.8.0"
135149
flutter_state_notifier:
136150
dependency: transitive
137151
description:
138152
name: flutter_state_notifier
139153
url: "https://pub.dartlang.org"
140154
source: hosted
141-
version: "0.4.2"
155+
version: "0.6.1"
142156
flutter_test:
143157
dependency: "direct dev"
144158
description: flutter
@@ -155,7 +169,7 @@ packages:
155169
name: freezed_annotation
156170
url: "https://pub.dartlang.org"
157171
source: hosted
158-
version: "0.11.0"
172+
version: "0.11.0+1"
159173
google_sign_in:
160174
dependency: transitive
161175
description:
@@ -211,7 +225,7 @@ packages:
211225
path: ".."
212226
relative: true
213227
source: path
214-
version: "0.1.3"
228+
version: "0.2.0"
215229
matcher:
216230
dependency: transitive
217231
description:
@@ -268,13 +282,6 @@ packages:
268282
url: "https://pub.dartlang.org"
269283
source: hosted
270284
version: "2.1.3"
271-
sign_in_with_apple:
272-
dependency: transitive
273-
description:
274-
name: sign_in_with_apple
275-
url: "https://pub.dartlang.org"
276-
source: hosted
277-
version: "2.5.2"
278285
sky_engine:
279286
dependency: transitive
280287
description: flutter
@@ -300,7 +307,7 @@ packages:
300307
name: state_notifier
301308
url: "https://pub.dartlang.org"
302309
source: hosted
303-
version: "0.5.0"
310+
version: "0.6.0"
304311
stream_channel:
305312
dependency: transitive
306313
description:

graphics/apple_logo_black.png

1.01 KB
Loading

graphics/apple_logo_white.png

881 Bytes
Loading

graphics/github.png

2.56 KB
Loading

graphics/google_logo.png

6.87 KB
Loading

graphics/twitter_logo_blue.png

4.2 KB
Loading

lib/lit_firebase_auth.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
export 'package:sign_in_with_apple/sign_in_with_apple.dart';
2-
31
export 'src/domain/auth/auth_providers.dart';
42
export 'src/domain/auth/i_auth_facade.dart';
53
export 'src/infrastructure/firebase_auth_facade.dart';

0 commit comments

Comments
 (0)