@@ -41,20 +41,20 @@ Firebase: see the
41
41
Then, add the FirebaseUI auth library dependency. If your project uses
42
42
Gradle, add:
43
43
44
- ```
44
+ ``` groovy
45
45
dependencies {
46
46
// ...
47
- compile 'com.firebaseui:firebase-ui-auth:0.5.1 '
47
+ compile 'com.firebaseui:firebase-ui-auth:0.5.3 '
48
48
}
49
49
```
50
50
51
51
If instead your project uses Maven, add:
52
52
53
- ```
53
+ ``` xml
54
54
<dependency >
55
55
<groupId >com.firebaseui</groupId >
56
56
<artifactId >firebase-ui-auth</artifactId >
57
- <version>0.5.1 </version>
57
+ <version >0.5.3 </version >
58
58
</dependency >
59
59
```
60
60
@@ -70,7 +70,7 @@ If support for Facebook Sign-in is also required, define the
70
70
resource string ` facebook_application_id ` to match the application ID in
71
71
the [ Facebook developer dashboard] ( https://developers.facebook.com ) :
72
72
73
- ```
73
+ ``` xml
74
74
<resources >
75
75
<!-- ... -->
76
76
<string name =" facebook_application_id" translatable =" false" >APPID</string >
@@ -95,7 +95,7 @@ Before invoking the FirebaseUI authentication flow, your app should check
95
95
whether a
96
96
[ user is already signed in] ( https://firebase.google.com/docs/auth/android/manage-users#get_the_currently_signed-in_user ) from a previous session:
97
97
98
- ```
98
+ ``` java
99
99
FirebaseAuth auth = FirebaseAuth . getInstance();
100
100
if (auth. getCurrentUser() != null ) {
101
101
// already signed in
@@ -127,15 +127,15 @@ The builder provides the following customization options for the authentication
127
127
a link in the small-print of the account creation step for new users. If no
128
128
terms of service URL is provided, the associated small-print is omitted.
129
129
130
- - A custom theme can specified for the flow, which is applied to all the
130
+ - A custom theme can be specified for the flow, which is applied to all the
131
131
activities in the flow for consistent customization of colors and typography.
132
132
133
133
#### Sign-in examples
134
134
135
135
If no customization is required, and only email authentication is required, the sign-in flow
136
136
can be started as follows:
137
137
138
- ```
138
+ ``` java
139
139
startActivityForResult(
140
140
// Get an instance of AuthUI based on the default app
141
141
AuthUI . getInstance(). createSignInIntentBuilder(). build(),
@@ -145,7 +145,7 @@ startActivityForResult(
145
145
You can enable sign-in providers like Google Sign-In or Facebook Log In by calling the
146
146
` setProviders ` method:
147
147
148
- ```
148
+ ``` java
149
149
startActivityForResult(
150
150
AuthUI . getInstance()
151
151
.createSignInIntentBuilder()
@@ -159,7 +159,7 @@ startActivityForResult(
159
159
160
160
If a terms of service URL and a custom theme are required:
161
161
162
- ```
162
+ ``` java
163
163
startActivityForResult(
164
164
AuthUI . getInstance()
165
165
.createSignInIntentBuilder()
@@ -176,7 +176,7 @@ Using SmartLock is recommended to provide the best user experience, but in some
176
176
to disable SmartLock for testing or development. To disable SmartLock, you can use the
177
177
` setIsSmartLockEnabled ` method when building your sign-in Intent:
178
178
179
- ```
179
+ ``` java
180
180
startActivityForResult(
181
181
AuthUI . getInstance()
182
182
.createSignInIntentBuilder()
@@ -188,7 +188,7 @@ startActivityForResult(
188
188
It is often desirable to disable SmartLock in development but enable it in production. To achieve
189
189
this, you can use the ` BuildConfig.DEBUG ` flag to control SmartLock:
190
190
191
- ```
191
+ ``` java
192
192
startActivityForResult(
193
193
AuthUI . getInstance()
194
194
.createSignInIntentBuilder()
@@ -206,7 +206,7 @@ typically useful; the only recourse for most apps if sign in fails is to ask
206
206
the user to sign in again later, or proceed with an anonymous account if
207
207
supported.
208
208
209
- ```
209
+ ``` java
210
210
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
211
211
super . onActivityResult(requestCode, resultCode, data);
212
212
if (requestCode == RC_SIGN_IN ) {
@@ -246,7 +246,7 @@ In order to make this process easier, AuthUI provides a simple `signOut` method
246
246
to encapsulate this behavior. The method returns a ` Task ` which is marked
247
247
completed once all necessary sign-out operations are completed:
248
248
249
- ```
249
+ ``` java
250
250
public void onClick(View v) {
251
251
if (v. getId() == R . id. sign_out) {
252
252
AuthUI . getInstance()
@@ -303,7 +303,7 @@ the flow, a new theme can be declared. Standard material design color
303
303
and typography properties will take effect as expected. For example, to define
304
304
a green theme:
305
305
306
- ```
306
+ ``` xml
307
307
<style name =" GreenTheme" parent =" FirebaseUI" >
308
308
<item name =" colorPrimary" >@color/material_green_500</item >
309
309
<item name =" colorPrimaryDark" >@color/material_green_700</item >
@@ -317,7 +317,7 @@ a green theme:
317
317
318
318
With associated colors:
319
319
320
- ```
320
+ ``` xml
321
321
<color name =" material_green_50" >#E8F5E9</color >
322
322
<color name =" material_green_500" >#4CAF50</color >
323
323
<color name =" material_green_700" >#388E3C</color >
@@ -328,7 +328,7 @@ With associated colors:
328
328
329
329
This would then be used in the construction of the sign-in intent:
330
330
331
- ```
331
+ ``` java
332
332
startActivityForResult(
333
333
AuthUI . getInstance(this ). createSignInIntentBuilder()
334
334
// ...
@@ -344,7 +344,7 @@ easily overridden by name in your application. See
344
344
[ the built-in strings.xml] ( src/main/res/values/strings.xml ) and simply
345
345
redefine a string to change it, for example:
346
346
347
- ```
347
+ ``` java
348
348
< resources>
349
349
< ! -- was " Signing up..." -- >
350
350
< string name= " progress_dialog_signing_up" > Creating your shiny new account...</string>
@@ -353,24 +353,37 @@ redefine a string to change it, for example:
353
353
354
354
### OAuth Scope Customization
355
355
356
+ #### Google
357
+ By default, FirebaseUI requests the `email` and `profile` scopes when using Google Sign In. If you
358
+ would like to request additional scopes from the user, add a string array resource named
359
+ `google_permissions` to your `strings.xml` file like this:
360
+
361
+ ```xml
362
+ <!--
363
+ For a list of all scopes, see:
364
+ https://developers.google.com/identity/protocols/googlescopes
365
+ -->
366
+ <string-array name="google_permissions">
367
+ <!-- Request permission to read the user's Google Drive files -->
368
+ <item>https://www.googleapis.com/auth/drive.readonly</item>
369
+ </string-array>
370
+ ```
371
+
372
+
356
373
#### Facebook
357
374
358
375
By default, FirebaseUI requests the `email` and `public_profile` permissions when initiating
359
- Facebook Login. If you would like to override these scopes, add a string array resource
360
- to your application like this:
376
+ Facebook Login. If you would like to override these scopes, a string array resource named
377
+ `facebook_permissions` to your `strings.xml` file like this:
361
378
362
- ```
379
+ ```xml
363
380
<!--
364
381
See:
365
382
https://developers.facebook.com/docs/facebook-login/android
366
383
https://developers.facebook.com/docs/facebook-login/permissions
367
384
-->
368
- <array name="facebook_permissions">
369
- <item>public_profile</item>
370
- <item>email</item>
371
- <!-- ... -->
372
- </array>
385
+ <string-array name="facebook_permissions">
386
+ <!-- Request permission to know the user's birthday -->
387
+ <item>user_birthday</item>
388
+ </string-array>
373
389
```
374
-
375
- Note that if you do not include at least the ` email ` and ` public_profile ` scopes, FirebaseUI
376
- will not work properly.
0 commit comments