Skip to content

Commit 19b3c11

Browse files
docs: add additional authentication providers
1 parent e4af6d1 commit 19b3c11

File tree

2 files changed

+65
-25
lines changed

2 files changed

+65
-25
lines changed

README.md

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ class MyApp extends StatelessWidget {
1111
authProviders: AuthProviders(
1212
emailAndPassword: true, // enabled by default
1313
google: true,
14+
apple: true,
1415
anonymous: true,
1516
github: true,
17+
twitter: true,
1618
// apple: AppleAuthProvider(
1719
// // required for web-based authentication flows
1820
// webAuthenticationOptions: WebAuthenticationOptions(
@@ -25,10 +27,15 @@ class MyApp extends StatelessWidget {
2527
),
2628
child: MaterialApp(
2729
title: 'Material App',
30+
themeMode: ThemeMode.light,
31+
darkTheme: ThemeData.dark(),
2832
theme: ThemeData(
29-
primaryColor: Colors.blueGrey,
30-
accentColor: Colors.pink[400],
3133
visualDensity: VisualDensity.adaptivePlatformDensity,
34+
buttonTheme: ButtonThemeData(
35+
buttonColor: Colors.white,
36+
textTheme: ButtonTextTheme.primary,
37+
height: 40,
38+
),
3239
),
3340
home: SplashScreen(),
3441
),
@@ -57,6 +64,8 @@ class SplashScreen extends StatelessWidget {
5764
textAlign: TextAlign.center,
5865
style: Theme.of(context).textTheme.headline4,
5966
),
67+
googleButton: GoogleButtonConfig.light(),
68+
appleButton: AppleButtonConfig.dark(),
6069
),
6170
),
6271

0 commit comments

Comments
 (0)