@@ -26,11 +26,10 @@ FirebaseUI Auth clients are also available for [iOS](https://github.com/firebase
26
26
27
27
## Installation
28
28
29
- You just need to include the following code in the ` <head> ` tag of your page:
29
+ You just need to include the following script and CSS file in the ` <head> ` tag of your page,
30
+ below the initialization snippet from the Firebase Console:
30
31
31
32
``` html
32
- <script src =" https://www.gstatic.com/firebasejs/live/3.0/firebase-app.js" ></script >
33
- <script src =" https://www.gstatic.com/firebasejs/live/3.0/firebase-auth.js" ></script >
34
33
<script src =" https://www.gstatic.com/firebasejs/ui/live/0.4/firebase-ui-auth.js" ></script >
35
34
<link type =" text/css" rel =" stylesheet" href =" https://www.gstatic.com/firebasejs/ui/live/0.4/firebase-ui-auth.css" />
36
35
```
@@ -75,20 +74,18 @@ The following example shows how to set up a sign-in screen with all supported pr
75
74
<head >
76
75
<meta charset =" UTF-8" >
77
76
<title >Sample FirebaseUI App</title >
78
- <script src =" firebase-app.js" ></script >
79
- <script src =" firebase-auth.js" ></script >
80
- <script src =" firebase-ui-auth.js" ></script >
77
+ <!-- *******************************************************************************************
78
+ * TODO(DEVELOPER): Paste the initialization snippet from:
79
+ * Firebase Console > Overview > Add Firebase to your web app. *
80
+ ***************************************************************************************** -->
81
+ <script src =" https://www.gstatic.com/firebasejs/ui/live/0.4/firebase-ui-auth.js" ></script >
82
+ <link type =" text/css" rel =" stylesheet" href =" https://www.gstatic.com/firebasejs/ui/live/0.4/firebase-ui-auth.css" />
81
83
<script type =" text/javascript" >
82
- // Firebase config.
83
- var config = {
84
- ' authDomain' : ' <your-firebase-project-domain>.firebaseapp.com' ,
85
- ' apiKey' : ' <your-API-key>' ,
86
- };
87
-
88
84
// FirebaseUI config.
89
85
var uiConfig = {
90
86
' signInSuccessUrl' : ' <url-to-redirect-to-on-success>' ,
91
87
' signInOptions' : [
88
+ // Leave the lines as is for the providers you want to offer your users.
92
89
firebase .auth .GoogleAuthProvider .PROVIDER_ID ,
93
90
firebase .auth .FacebookAuthProvider .PROVIDER_ID ,
94
91
firebase .auth .TwitterAuthProvider .PROVIDER_ID ,
@@ -100,13 +97,10 @@ The following example shows how to set up a sign-in screen with all supported pr
100
97
};
101
98
102
99
// Initialize the FirebaseUI Widget using Firebase.
103
- var app = firebase .initializeApp (config);
104
- var auth = app .auth ();
105
- var ui = new firebaseui.auth.AuthUI (auth);
100
+ var ui = new firebaseui.auth.AuthUI (firebase .auth ());
106
101
// The start method will wait until the DOM is loaded.
107
102
ui .start (' #firebaseui-auth-container' , uiConfig);
108
103
</script >
109
- <link type =" text/css" rel =" stylesheet" href =" firebase-ui-auth.css" />
110
104
</head >
111
105
<body >
112
106
<!-- The surrounding HTML is left untouched by FirebaseUI.
@@ -125,21 +119,13 @@ Here is how you would track the Auth state across all your pages:
125
119
<head >
126
120
<meta charset =" UTF-8" >
127
121
<title >Sample FirebaseUI App</title >
128
- <script src =" firebase-app.js" ></script >
129
- <script src =" firebase-auth.js" ></script >
122
+ <!-- *******************************************************************************************
123
+ * TODO(DEVELOPER): Paste the initialization snippet from:
124
+ * Firebase Console > Overview > Add Firebase to your web app. *
125
+ ***************************************************************************************** -->
130
126
<script type =" text/javascript" >
131
- // Firebase config.
132
- var config = {
133
- ' authDomain' : ' <your-firebase-project-domain>.firebaseapp.com' ,
134
- ' apiKey' : ' <your-API-key>' ,
135
- };
136
-
137
- // Instantiates the Firebase Auth instance.
138
- var app = firebase .initializeApp (config);
139
- var auth = app .auth ();
140
-
141
127
initApp = function () {
142
- auth .onAuthStateChanged (function (user ) {
128
+ firebase . auth () .onAuthStateChanged (function (user ) {
143
129
if (user) {
144
130
// User is signed in.
145
131
var displayName = user .displayName ;
@@ -149,9 +135,9 @@ Here is how you would track the Auth state across all your pages:
149
135
var uid = user .uid ;
150
136
var providerData = user .providerData ;
151
137
user .getToken ().then (function (accessToken ) {
152
- document .getElementById (' quickstart- sign-in-status' ).textContent = ' Signed in' ;
153
- document .getElementById (' quickstart- sign-in' ).textContent = ' Sign out' ;
154
- document .getElementById (' quickstart- account-details' ).textContent = JSON .stringify ({
138
+ document .getElementById (' sign-in-status' ).textContent = ' Signed in' ;
139
+ document .getElementById (' sign-in' ).textContent = ' Sign out' ;
140
+ document .getElementById (' account-details' ).textContent = JSON .stringify ({
155
141
displayName: displayName,
156
142
email: email,
157
143
emailVerified: emailVerified,
@@ -163,25 +149,25 @@ Here is how you would track the Auth state across all your pages:
163
149
});
164
150
} else {
165
151
// User is signed out.
166
- document .getElementById (' quickstart- sign-in-status' ).textContent = ' Signed out' ;
167
- document .getElementById (' quickstart- sign-in' ).textContent = ' Sign in' ;
168
- document .getElementById (' quickstart- account-details' ).textContent = ' null' ;
152
+ document .getElementById (' sign-in-status' ).textContent = ' Signed out' ;
153
+ document .getElementById (' sign-in' ).textContent = ' Sign in' ;
154
+ document .getElementById (' account-details' ).textContent = ' null' ;
169
155
}
170
156
}, function (error ) {
171
157
console .log (error);
172
158
});
173
159
};
174
160
175
- window .onload = function () {
161
+ window .addEventListener ( ' load ' , function () {
176
162
initApp ()
177
- };
163
+ }) ;
178
164
</script >
179
165
</head >
180
166
<body >
181
167
<h1 >Welcome to My Awesome App</h1 >
182
- <div id =" quickstart- sign-in-status" ></div >
183
- <div id =" quickstart- sign-in" ></div >
184
- <div id =" quickstart- account-details" ></div >
168
+ <div id =" sign-in-status" ></div >
169
+ <div id =" sign-in" ></div >
170
+ <div id =" account-details" ></div >
185
171
</body >
186
172
</html >
187
173
@@ -245,16 +231,13 @@ If the callback returns `false` or nothing, the page is not automatically redire
245
231
<head >
246
232
<meta charset =" UTF-8" >
247
233
<title >Sample FirebaseUI App</title >
248
- <script src =" firebase-app.js" ></script >
249
- <script src =" firebase-auth.js" ></script >
250
- <script src =" firebase-ui-auth.js" ></script >
234
+ <!-- *******************************************************************************************
235
+ * TODO(DEVELOPER): Paste the initialization snippet from:
236
+ * Firebase Console > Overview > Add Firebase to your web app. *
237
+ ***************************************************************************************** -->
238
+ <script src =" https://www.gstatic.com/firebasejs/ui/live/0.4/firebase-ui-auth.js" ></script >
239
+ <link type =" text/css" rel =" stylesheet" href =" https://www.gstatic.com/firebasejs/ui/live/0.4/firebase-ui-auth.css" />
251
240
<script type =" text/javascript" >
252
- // Firebase config.
253
- var config = {
254
- ' authDomain' : ' <your-firebase-project-domain>.firebaseapp.com' ,
255
- ' apiKey' : ' <your-API-key>' ,
256
- };
257
-
258
241
// FirebaseUI config.
259
242
var uiConfig = {
260
243
// Query parameter name for mode.
@@ -263,6 +246,7 @@ If the callback returns `false` or nothing, the page is not automatically redire
263
246
' queryParameterForSignInSuccessUrl' : ' signInSuccessUrl' ,
264
247
' signInSuccessUrl' : ' <url-to-redirect-to-on-success>' ,
265
248
' signInOptions' : [
249
+ // Leave the lines as is for the providers you want to offer your users.
266
250
firebase .auth .GoogleAuthProvider .PROVIDER_ID ,
267
251
firebase .auth .FacebookAuthProvider .PROVIDER_ID ,
268
252
firebase .auth .TwitterAuthProvider .PROVIDER_ID ,
@@ -280,14 +264,10 @@ If the callback returns `false` or nothing, the page is not automatically redire
280
264
}
281
265
};
282
266
283
- // Initialize the FirebaseUI Widget using Firebase.
284
- var app = firebase .initializeApp (config);
285
- var auth = app .auth ();
286
- var ui = new firebaseui.auth.AuthUI (auth);
267
+ var ui = new firebaseui.auth.AuthUI (firebase .auth ());
287
268
// The start method will wait until the DOM is loaded.
288
269
ui .start (' #firebaseui-auth-container' , uiConfig);
289
270
</script >
290
- <link type =" text/css" rel =" stylesheet" href =" firebase-ui-auth.css" />
291
271
</head >
292
272
<body >
293
273
<!-- The surrounding HTML is left untouched by FirebaseUI.
0 commit comments