Skip to content

Commit 054689e

Browse files
committed
Merge pull request #101 from nicolasgarnier/add-oauth-login
Add support for headless login to firebase-auth
2 parents 09aa7d5 + b6952e7 commit 054689e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

firebase-auth.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,17 @@
187187
* provider-specific login parameters can be specified via attribute (JSON)/property,
188188
* or via the `params` argument to the `login` function.
189189
*
190+
* If your `provider` is `custom` you must pass a Firebase Auth token as
191+
* `params.token`. You can also optionally pass an auth token as `params.token` for
192+
* providers `facebook`, `google`, `github` and `twitter` to login headlessly.
193+
*
190194
* If the login is successful, the `login` event is fired, with `e.detail.user`
191195
* containing the authenticated user object from Firebase.
192196
*
193197
* If login fails, the `error` event is fired, with `e.detail` containing error
194198
* information supplied from Firebase.
195199
*
196-
* If the browswer supports `navigator.onLine` network status reporting and the
200+
* If the browser supports `navigator.onLine` network status reporting and the
197201
* network is currently offline, the login attempt will be queued until the network
198202
* is restored.
199203
*
@@ -221,7 +225,9 @@
221225
case 'google':
222226
case 'github':
223227
case 'twitter':
224-
if (this.redirect) {
228+
if (params.token) {
229+
this.ref.authWithOAuthToken(this.provider, params.token, this._loginHandler.bind(this), params);
230+
} else if (this.redirect) {
225231
this.ref.authWithOAuthRedirect(this.provider, this._loginHandler.bind(this), params);
226232
} else {
227233
this.ref.authWithOAuthPopup(this.provider, this._loginHandler.bind(this), params);

0 commit comments

Comments
 (0)