-
Notifications
You must be signed in to change notification settings - Fork 892
/
auth.md
2116 lines (1439 loc) · 90.3 KB
/
auth.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Project: /docs/reference/js/_project.yaml
Book: /docs/reference/_book.yaml
page_type: reference
{% comment %}
DO NOT EDIT THIS FILE!
This is generated by the JS SDK team, and any local changes will be
overwritten. Changes should be made in the source code at
https://github.com/firebase/firebase-js-sdk
{% endcomment %}
# auth package
Firebase Authentication
## Functions
| Function | Description |
| --- | --- |
| <b>function(app...)</b> |
| [getAuth(app)](./auth.md#getauth) | Returns the Auth instance associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface)<!-- -->. If no instance exists, initializes an Auth instance with platform-specific default dependencies. |
| [initializeAuth(app, deps)](./auth.md#initializeauth) | Initializes an [Auth](./auth.auth.md#auth_interface) instance with fine-grained control over [Dependencies](./auth.dependencies.md#dependencies_interface)<!-- -->. |
| <b>function(storage...)</b> |
| [getReactNativePersistence(storage)](./auth.md#getreactnativepersistence) | Returns a persistence object that wraps <code>AsyncStorage</code> imported from <code>react-native</code> or <code>@react-native-community/async-storage</code>, and can be used in the persistence dependency field in [initializeAuth()](./auth.md#initializeauth)<!-- -->. |
| <b>function(auth...)</b> |
| [applyActionCode(auth, oobCode)](./auth.md#applyactioncode) | Applies a verification code sent to the user by email or other out-of-band mechanism. |
| [beforeAuthStateChanged(auth, callback, onAbort)](./auth.md#beforeauthstatechanged) | Adds a blocking callback that runs before an auth state change sets a new user. |
| [checkActionCode(auth, oobCode)](./auth.md#checkactioncode) | Checks a verification code sent to the user by email or other out-of-band mechanism. |
| [confirmPasswordReset(auth, oobCode, newPassword)](./auth.md#confirmpasswordreset) | Completes the password reset process, given a confirmation code and new password. |
| [connectAuthEmulator(auth, url, options)](./auth.md#connectauthemulator) | Changes the [Auth](./auth.auth.md#auth_interface) instance to communicate with the Firebase Auth Emulator, instead of production Firebase Auth services. |
| [createUserWithEmailAndPassword(auth, email, password)](./auth.md#createuserwithemailandpassword) | Creates a new user account associated with the specified email address and password. |
| [fetchSignInMethodsForEmail(auth, email)](./auth.md#fetchsigninmethodsforemail) | Gets the list of possible sign in methods for the given email address. This method returns an empty list when \[Email Enumeration Protection\](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled, irrespective of the number of authentication methods available for the given email. |
| [getMultiFactorResolver(auth, error)](./auth.md#getmultifactorresolver) | Provides a [MultiFactorResolver](./auth.multifactorresolver.md#multifactorresolver_interface) suitable for completion of a multi-factor flow. |
| [getRedirectResult(auth, resolver)](./auth.md#getredirectresult) | Returns a [UserCredential](./auth.usercredential.md#usercredential_interface) from the redirect-based sign-in flow. |
| [initializeRecaptchaConfig(auth)](./auth.md#initializerecaptchaconfig) | Loads the reCAPTCHA configuration into the <code>Auth</code> instance. |
| [isSignInWithEmailLink(auth, emailLink)](./auth.md#issigninwithemaillink) | Checks if an incoming link is a sign-in with email link suitable for [signInWithEmailLink()](./auth.md#signinwithemaillink)<!-- -->. |
| [onAuthStateChanged(auth, nextOrObserver, error, completed)](./auth.md#onauthstatechanged) | Adds an observer for changes to the user's sign-in state. |
| [onIdTokenChanged(auth, nextOrObserver, error, completed)](./auth.md#onidtokenchanged) | Adds an observer for changes to the signed-in user's ID token. |
| [revokeAccessToken(auth, token)](./auth.md#revokeaccesstoken) | Revokes the given access token. Currently only supports Apple OAuth access tokens. |
| [sendPasswordResetEmail(auth, email, actionCodeSettings)](./auth.md#sendpasswordresetemail) | Sends a password reset email to the given email address. This method does not throw an error when there's no user account with the given email address and \[Email Enumeration Protection\](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled. |
| [sendSignInLinkToEmail(auth, email, actionCodeSettings)](./auth.md#sendsigninlinktoemail) | Sends a sign-in email link to the user with the specified email. |
| [setPersistence(auth, persistence)](./auth.md#setpersistence) | Changes the type of persistence on the [Auth](./auth.auth.md#auth_interface) instance for the currently saved <code>Auth</code> session and applies this type of persistence for future sign-in requests, including sign-in with redirect requests. |
| [signInAnonymously(auth)](./auth.md#signinanonymously) | Asynchronously signs in as an anonymous user. |
| [signInWithCredential(auth, credential)](./auth.md#signinwithcredential) | Asynchronously signs in with the given credentials. |
| [signInWithCustomToken(auth, customToken)](./auth.md#signinwithcustomtoken) | Asynchronously signs in using a custom token. |
| [signInWithEmailAndPassword(auth, email, password)](./auth.md#signinwithemailandpassword) | Asynchronously signs in using an email and password. |
| [signInWithEmailLink(auth, email, emailLink)](./auth.md#signinwithemaillink) | Asynchronously signs in using an email and sign-in email link. |
| [signInWithPhoneNumber(auth, phoneNumber, appVerifier)](./auth.md#signinwithphonenumber) | Asynchronously signs in using a phone number. |
| [signInWithPopup(auth, provider, resolver)](./auth.md#signinwithpopup) | Authenticates a Firebase client using a popup-based OAuth authentication flow. |
| [signInWithRedirect(auth, provider, resolver)](./auth.md#signinwithredirect) | Authenticates a Firebase client using a full-page redirect flow. |
| [signOut(auth)](./auth.md#signout) | Signs out the current user. |
| [updateCurrentUser(auth, user)](./auth.md#updatecurrentuser) | Asynchronously sets the provided user as [Auth.currentUser](./auth.auth.md#authcurrentuser) on the [Auth](./auth.auth.md#auth_interface) instance. |
| [useDeviceLanguage(auth)](./auth.md#usedevicelanguage) | Sets the current language to the default device/browser preference. |
| [validatePassword(auth, password)](./auth.md#validatepassword) | Validates the password against the password policy configured for the project or tenant. |
| [verifyPasswordResetCode(auth, code)](./auth.md#verifypasswordresetcode) | Checks a password reset code sent to the user by email or other out-of-band mechanism. |
| <b>function(link...)</b> |
| [parseActionCodeURL(link)](./auth.md#parseactioncodeurl) | Parses the email action link string and returns an [ActionCodeURL](./auth.actioncodeurl.md#actioncodeurl_class) if the link is valid, otherwise returns null. |
| <b>function(user...)</b> |
| [deleteUser(user)](./auth.md#deleteuser) | Deletes and signs out the user. |
| [getIdToken(user, forceRefresh)](./auth.md#getidtoken) | Returns a JSON Web Token (JWT) used to identify the user to a Firebase service. |
| [getIdTokenResult(user, forceRefresh)](./auth.md#getidtokenresult) | Returns a deserialized JSON Web Token (JWT) used to identify the user to a Firebase service. |
| [linkWithCredential(user, credential)](./auth.md#linkwithcredential) | Links the user account with the given credentials. |
| [linkWithPhoneNumber(user, phoneNumber, appVerifier)](./auth.md#linkwithphonenumber) | Links the user account with the given phone number. |
| [linkWithPopup(user, provider, resolver)](./auth.md#linkwithpopup) | Links the authenticated provider to the user account using a pop-up based OAuth flow. |
| [linkWithRedirect(user, provider, resolver)](./auth.md#linkwithredirect) | Links the [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class) to the user account using a full-page redirect flow. |
| [multiFactor(user)](./auth.md#multifactor) | The [MultiFactorUser](./auth.multifactoruser.md#multifactoruser_interface) corresponding to the user. |
| [reauthenticateWithCredential(user, credential)](./auth.md#reauthenticatewithcredential) | Re-authenticates a user using a fresh credential. |
| [reauthenticateWithPhoneNumber(user, phoneNumber, appVerifier)](./auth.md#reauthenticatewithphonenumber) | Re-authenticates a user using a fresh phone credential. |
| [reauthenticateWithPopup(user, provider, resolver)](./auth.md#reauthenticatewithpopup) | Reauthenticates the current user with the specified [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class) using a pop-up based OAuth flow. |
| [reauthenticateWithRedirect(user, provider, resolver)](./auth.md#reauthenticatewithredirect) | Reauthenticates the current user with the specified [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class) using a full-page redirect flow. |
| [reload(user)](./auth.md#reload) | Reloads user account data, if signed in. |
| [sendEmailVerification(user, actionCodeSettings)](./auth.md#sendemailverification) | Sends a verification email to a user. |
| [unlink(user, providerId)](./auth.md#unlink) | Unlinks a provider from a user account. |
| [updateEmail(user, newEmail)](./auth.md#updateemail) | Updates the user's email address. |
| [updatePassword(user, newPassword)](./auth.md#updatepassword) | Updates the user's password. |
| [updatePhoneNumber(user, credential)](./auth.md#updatephonenumber) | Updates the user's phone number. |
| [updateProfile(user, { displayName, photoURL: photoUrl })](./auth.md#updateprofile) | Updates a user's profile data. |
| [verifyBeforeUpdateEmail(user, newEmail, actionCodeSettings)](./auth.md#verifybeforeupdateemail) | Sends a verification email to a new email address. |
| <b>function(userCredential...)</b> |
| [getAdditionalUserInfo(userCredential)](./auth.md#getadditionaluserinfo) | Extracts provider specific [AdditionalUserInfo](./auth.additionaluserinfo.md#additionaluserinfo_interface) for the given credential. |
## Classes
| Class | Description |
| --- | --- |
| [ActionCodeURL](./auth.actioncodeurl.md#actioncodeurl_class) | A utility class to parse email action URLs such as password reset, email verification, email link sign in, etc. |
| [AuthCredential](./auth.authcredential.md#authcredential_class) | Interface that represents the credentials returned by an [AuthProvider](./auth.authprovider.md#authprovider_interface)<!-- -->. |
| [EmailAuthCredential](./auth.emailauthcredential.md#emailauthcredential_class) | Interface that represents the credentials returned by [EmailAuthProvider](./auth.emailauthprovider.md#emailauthprovider_class) for [ProviderId](./auth.md#providerid)<!-- -->.PASSWORD |
| [EmailAuthProvider](./auth.emailauthprovider.md#emailauthprovider_class) | Provider for generating [EmailAuthCredential](./auth.emailauthcredential.md#emailauthcredential_class)<!-- -->. |
| [FacebookAuthProvider](./auth.facebookauthprovider.md#facebookauthprovider_class) | Provider for generating an [OAuthCredential](./auth.oauthcredential.md#oauthcredential_class) for [ProviderId](./auth.md#providerid)<!-- -->.FACEBOOK. |
| [GithubAuthProvider](./auth.githubauthprovider.md#githubauthprovider_class) | Provider for generating an [OAuthCredential](./auth.oauthcredential.md#oauthcredential_class) for [ProviderId](./auth.md#providerid)<!-- -->.GITHUB. |
| [GoogleAuthProvider](./auth.googleauthprovider.md#googleauthprovider_class) | Provider for generating an an [OAuthCredential](./auth.oauthcredential.md#oauthcredential_class) for [ProviderId](./auth.md#providerid)<!-- -->.GOOGLE. |
| [OAuthCredential](./auth.oauthcredential.md#oauthcredential_class) | Represents the OAuth credentials returned by an [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class)<!-- -->. |
| [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class) | Provider for generating generic [OAuthCredential](./auth.oauthcredential.md#oauthcredential_class)<!-- -->. |
| [PhoneAuthCredential](./auth.phoneauthcredential.md#phoneauthcredential_class) | Represents the credentials returned by [PhoneAuthProvider](./auth.phoneauthprovider.md#phoneauthprovider_class)<!-- -->. |
| [PhoneAuthProvider](./auth.phoneauthprovider.md#phoneauthprovider_class) | Provider for generating an [PhoneAuthCredential](./auth.phoneauthcredential.md#phoneauthcredential_class)<!-- -->. |
| [PhoneMultiFactorGenerator](./auth.phonemultifactorgenerator.md#phonemultifactorgenerator_class) | Provider for generating a [PhoneMultiFactorAssertion](./auth.phonemultifactorassertion.md#phonemultifactorassertion_interface)<!-- -->. |
| [RecaptchaVerifier](./auth.recaptchaverifier.md#recaptchaverifier_class) | An [reCAPTCHA](https://www.google.com/recaptcha/)<!-- -->-based application verifier. |
| [SAMLAuthProvider](./auth.samlauthprovider.md#samlauthprovider_class) | An [AuthProvider](./auth.authprovider.md#authprovider_interface) for SAML. |
| [TotpMultiFactorGenerator](./auth.totpmultifactorgenerator.md#totpmultifactorgenerator_class) | Provider for generating a [TotpMultiFactorAssertion](./auth.totpmultifactorassertion.md#totpmultifactorassertion_interface)<!-- -->. |
| [TotpSecret](./auth.totpsecret.md#totpsecret_class) | Provider for generating a [TotpMultiFactorAssertion](./auth.totpmultifactorassertion.md#totpmultifactorassertion_interface)<!-- -->.<!-- -->Stores the shared secret key and other parameters to generate time-based OTPs. Implements methods to retrieve the shared secret key and generate a QR code URL. |
| [TwitterAuthProvider](./auth.twitterauthprovider.md#twitterauthprovider_class) | Provider for generating an [OAuthCredential](./auth.oauthcredential.md#oauthcredential_class) for [ProviderId](./auth.md#providerid)<!-- -->.TWITTER. |
## Interfaces
| Interface | Description |
| --- | --- |
| [ActionCodeInfo](./auth.actioncodeinfo.md#actioncodeinfo_interface) | A response from [checkActionCode()](./auth.md#checkactioncode)<!-- -->. |
| [ActionCodeSettings](./auth.actioncodesettings.md#actioncodesettings_interface) | An interface that defines the required continue/state URL with optional Android and iOS bundle identifiers. |
| [AdditionalUserInfo](./auth.additionaluserinfo.md#additionaluserinfo_interface) | A structure containing additional user information from a federated identity provider. |
| [ApplicationVerifier](./auth.applicationverifier.md#applicationverifier_interface) | A verifier for domain verification and abuse prevention. |
| [Auth](./auth.auth.md#auth_interface) | Interface representing Firebase Auth service. |
| [AuthError](./auth.autherror.md#autherror_interface) | Interface for an <code>Auth</code> error. |
| [AuthErrorMap](./auth.autherrormap.md#autherrormap_interface) | A mapping of error codes to error messages. |
| [AuthProvider](./auth.authprovider.md#authprovider_interface) | Interface that represents an auth provider, used to facilitate creating [AuthCredential](./auth.authcredential.md#authcredential_class)<!-- -->. |
| [AuthSettings](./auth.authsettings.md#authsettings_interface) | Interface representing an [Auth](./auth.auth.md#auth_interface) instance's settings. |
| [Config](./auth.config.md#config_interface) | Interface representing the <code>Auth</code> config. |
| [ConfirmationResult](./auth.confirmationresult.md#confirmationresult_interface) | A result from a phone number sign-in, link, or reauthenticate call. |
| [Dependencies](./auth.dependencies.md#dependencies_interface) | The dependencies that can be used to initialize an [Auth](./auth.auth.md#auth_interface) instance. |
| [EmulatorConfig](./auth.emulatorconfig.md#emulatorconfig_interface) | Configuration of Firebase Authentication Emulator. |
| [IdTokenResult](./auth.idtokenresult.md#idtokenresult_interface) | Interface representing ID token result obtained from [User.getIdTokenResult()](./auth.user.md#usergetidtokenresult)<!-- -->. |
| [MultiFactorAssertion](./auth.multifactorassertion.md#multifactorassertion_interface) | The base class for asserting ownership of a second factor. |
| [MultiFactorError](./auth.multifactorerror.md#multifactorerror_interface) | The error thrown when the user needs to provide a second factor to sign in successfully. |
| [MultiFactorInfo](./auth.multifactorinfo.md#multifactorinfo_interface) | A structure containing the information of a second factor entity. |
| [MultiFactorResolver](./auth.multifactorresolver.md#multifactorresolver_interface) | The class used to facilitate recovery from [MultiFactorError](./auth.multifactorerror.md#multifactorerror_interface) when a user needs to provide a second factor to sign in. |
| [MultiFactorSession](./auth.multifactorsession.md#multifactorsession_interface) | An interface defining the multi-factor session object used for enrolling a second factor on a user or helping sign in an enrolled user with a second factor. |
| [MultiFactorUser](./auth.multifactoruser.md#multifactoruser_interface) | An interface that defines the multi-factor related properties and operations pertaining to a [User](./auth.user.md#user_interface)<!-- -->. |
| [OAuthCredentialOptions](./auth.oauthcredentialoptions.md#oauthcredentialoptions_interface) | Defines the options for initializing an [OAuthCredential](./auth.oauthcredential.md#oauthcredential_class)<!-- -->. |
| [ParsedToken](./auth.parsedtoken.md#parsedtoken_interface) | Interface representing a parsed ID token. |
| [PasswordPolicy](./auth.passwordpolicy.md#passwordpolicy_interface) | A structure specifying password policy requirements. |
| [PasswordValidationStatus](./auth.passwordvalidationstatus.md#passwordvalidationstatus_interface) | A structure indicating which password policy requirements were met or violated and what the requirements are. |
| [Persistence](./auth.persistence.md#persistence_interface) | An interface covering the possible persistence mechanism types. |
| [PhoneMultiFactorAssertion](./auth.phonemultifactorassertion.md#phonemultifactorassertion_interface) | The class for asserting ownership of a phone second factor. Provided by [PhoneMultiFactorGenerator.assertion()](./auth.phonemultifactorgenerator.md#phonemultifactorgeneratorassertion)<!-- -->. |
| [PhoneMultiFactorEnrollInfoOptions](./auth.phonemultifactorenrollinfooptions.md#phonemultifactorenrollinfooptions_interface) | Options used for enrolling a second factor. |
| [PhoneMultiFactorInfo](./auth.phonemultifactorinfo.md#phonemultifactorinfo_interface) | The subclass of the [MultiFactorInfo](./auth.multifactorinfo.md#multifactorinfo_interface) interface for phone number second factors. The <code>factorId</code> of this second factor is [FactorId](./auth.md#factorid)<!-- -->.PHONE. |
| [PhoneMultiFactorSignInInfoOptions](./auth.phonemultifactorsignininfooptions.md#phonemultifactorsignininfooptions_interface) | Options used for signing in with a second factor. |
| [PhoneSingleFactorInfoOptions](./auth.phonesinglefactorinfooptions.md#phonesinglefactorinfooptions_interface) | Options used for single-factor sign-in. |
| [PopupRedirectResolver](./auth.popupredirectresolver.md#popupredirectresolver_interface) | A resolver used for handling DOM specific operations like [signInWithPopup()](./auth.md#signinwithpopup) or [signInWithRedirect()](./auth.md#signinwithredirect)<!-- -->. |
| [ReactNativeAsyncStorage](./auth.reactnativeasyncstorage.md#reactnativeasyncstorage_interface) | Interface for a supplied <code>AsyncStorage</code>. |
| [RecaptchaParameters](./auth.recaptchaparameters.md#recaptchaparameters_interface) | Interface representing reCAPTCHA parameters.<!-- -->See the \[reCAPTCHA docs\](https://developers.google.com/recaptcha/docs/display\#render\_param) for the list of accepted parameters. All parameters are accepted except for <code>sitekey</code>: Firebase Auth provisions a reCAPTCHA for each project and will configure the site key upon rendering.<!-- -->For an invisible reCAPTCHA, set the <code>size</code> key to <code>invisible</code>. |
| [TotpMultiFactorAssertion](./auth.totpmultifactorassertion.md#totpmultifactorassertion_interface) | The class for asserting ownership of a TOTP second factor. Provided by [TotpMultiFactorGenerator.assertionForEnrollment()](./auth.totpmultifactorgenerator.md#totpmultifactorgeneratorassertionforenrollment) and [TotpMultiFactorGenerator.assertionForSignIn()](./auth.totpmultifactorgenerator.md#totpmultifactorgeneratorassertionforsignin)<!-- -->. |
| [TotpMultiFactorInfo](./auth.totpmultifactorinfo.md#totpmultifactorinfo_interface) | The subclass of the [MultiFactorInfo](./auth.multifactorinfo.md#multifactorinfo_interface) interface for TOTP second factors. The <code>factorId</code> of this second factor is [FactorId](./auth.md#factorid)<!-- -->.TOTP. |
| [User](./auth.user.md#user_interface) | A user account. |
| [UserCredential](./auth.usercredential.md#usercredential_interface) | A structure containing a [User](./auth.user.md#user_interface)<!-- -->, the [OperationType](./auth.md#operationtype)<!-- -->, and the provider ID. |
| [UserInfo](./auth.userinfo.md#userinfo_interface) | User profile information, visible only to the Firebase project's apps. |
| [UserMetadata](./auth.usermetadata.md#usermetadata_interface) | Interface representing a user's metadata. |
## Variables
| Variable | Description |
| --- | --- |
| [ActionCodeOperation](./auth.md#actioncodeoperation) | An enumeration of the possible email action types. |
| [AuthErrorCodes](./auth.md#autherrorcodes) | A map of potential <code>Auth</code> error codes, for easier comparison with errors thrown by the SDK. |
| [browserLocalPersistence](./auth.md#browserlocalpersistence) | An implementation of [Persistence](./auth.persistence.md#persistence_interface) of type <code>LOCAL</code> using <code>localStorage</code> for the underlying storage. |
| [browserPopupRedirectResolver](./auth.md#browserpopupredirectresolver) | An implementation of [PopupRedirectResolver](./auth.popupredirectresolver.md#popupredirectresolver_interface) suitable for browser based applications. |
| [browserSessionPersistence](./auth.md#browsersessionpersistence) | An implementation of [Persistence](./auth.persistence.md#persistence_interface) of <code>SESSION</code> using <code>sessionStorage</code> for the underlying storage. |
| [cordovaPopupRedirectResolver](./auth.md#cordovapopupredirectresolver) | An implementation of [PopupRedirectResolver](./auth.popupredirectresolver.md#popupredirectresolver_interface) suitable for Cordova based applications. |
| [debugErrorMap](./auth.md#debugerrormap) | A verbose error map with detailed descriptions for most error codes.<!-- -->See discussion at [AuthErrorMap](./auth.autherrormap.md#autherrormap_interface) |
| [FactorId](./auth.md#factorid) | An enum of factors that may be used for multifactor authentication. |
| [indexedDBLocalPersistence](./auth.md#indexeddblocalpersistence) | An implementation of [Persistence](./auth.persistence.md#persistence_interface) of type <code>LOCAL</code> using <code>indexedDB</code> for the underlying storage. |
| [inMemoryPersistence](./auth.md#inmemorypersistence) | An implementation of [Persistence](./auth.persistence.md#persistence_interface) of type 'NONE'. |
| [OperationType](./auth.md#operationtype) | Enumeration of supported operation types. |
| [prodErrorMap](./auth.md#proderrormap) | A minimal error map with all verbose error messages stripped.<!-- -->See discussion at [AuthErrorMap](./auth.autherrormap.md#autherrormap_interface) |
| [ProviderId](./auth.md#providerid) | Enumeration of supported providers. |
| [SignInMethod](./auth.md#signinmethod) | Enumeration of supported sign-in methods. |
## Type Aliases
| Type Alias | Description |
| --- | --- |
| [CustomParameters](./auth.md#customparameters) | Map of OAuth Custom Parameters. |
| [NextOrObserver](./auth.md#nextorobserver) | Type definition for an event callback. |
| [PhoneInfoOptions](./auth.md#phoneinfooptions) | The information required to verify the ownership of a phone number. |
| [UserProfile](./auth.md#userprofile) | User profile used in [AdditionalUserInfo](./auth.additionaluserinfo.md#additionaluserinfo_interface)<!-- -->. |
## getAuth()
Returns the Auth instance associated with the provided [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface)<!-- -->. If no instance exists, initializes an Auth instance with platform-specific default dependencies.
<b>Signature:</b>
```typescript
export declare function getAuth(app?: FirebaseApp): Auth;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The Firebase App. |
<b>Returns:</b>
[Auth](./auth.auth.md#auth_interface)
## initializeAuth()
Initializes an [Auth](./auth.auth.md#auth_interface) instance with fine-grained control over [Dependencies](./auth.dependencies.md#dependencies_interface)<!-- -->.
This function allows more control over the [Auth](./auth.auth.md#auth_interface) instance than [getAuth()](./auth.md#getauth)<!-- -->. `getAuth` uses platform-specific defaults to supply the [Dependencies](./auth.dependencies.md#dependencies_interface)<!-- -->. In general, `getAuth` is the easiest way to initialize Auth and works for most use cases. Use `initializeAuth` if you need control over which persistence layer is used, or to minimize bundle size if you're not using either `signInWithPopup` or `signInWithRedirect`<!-- -->.
For example, if your app only uses anonymous accounts and you only want accounts saved for the current session, initialize `Auth` with:
```js
const auth = initializeAuth(app, {
persistence: browserSessionPersistence,
popupRedirectResolver: undefined,
});
```
<b>Signature:</b>
```typescript
export declare function initializeAuth(app: FirebaseApp, deps?: Dependencies): Auth;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | |
| deps | [Dependencies](./auth.dependencies.md#dependencies_interface) | |
<b>Returns:</b>
[Auth](./auth.auth.md#auth_interface)
## getReactNativePersistence()
Returns a persistence object that wraps `AsyncStorage` imported from `react-native` or `@react-native-community/async-storage`<!-- -->, and can be used in the persistence dependency field in [initializeAuth()](./auth.md#initializeauth)<!-- -->.
<b>Signature:</b>
```typescript
export declare function getReactNativePersistence(storage: ReactNativeAsyncStorage): Persistence;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| storage | [ReactNativeAsyncStorage](./auth.reactnativeasyncstorage.md#reactnativeasyncstorage_interface) | |
<b>Returns:</b>
[Persistence](./auth.persistence.md#persistence_interface)
## applyActionCode()
Applies a verification code sent to the user by email or other out-of-band mechanism.
<b>Signature:</b>
```typescript
export declare function applyActionCode(auth: Auth, oobCode: string): Promise<void>;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| oobCode | string | A verification code sent to the user. |
<b>Returns:</b>
Promise<void>
## beforeAuthStateChanged()
Adds a blocking callback that runs before an auth state change sets a new user.
<b>Signature:</b>
```typescript
export declare function beforeAuthStateChanged(auth: Auth, callback: (user: User | null) => void | Promise<void>, onAbort?: () => void): Unsubscribe;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| callback | (user: [User](./auth.user.md#user_interface) \| null) => void \| Promise<void> | callback triggered before new user value is set. If this throws, it blocks the user from being set. |
| onAbort | () => void | callback triggered if a later <code>beforeAuthStateChanged()</code> callback throws, allowing you to undo any side effects. |
<b>Returns:</b>
[Unsubscribe](./util.md#unsubscribe)
## checkActionCode()
Checks a verification code sent to the user by email or other out-of-band mechanism.
<b>Signature:</b>
```typescript
export declare function checkActionCode(auth: Auth, oobCode: string): Promise<ActionCodeInfo>;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| oobCode | string | A verification code sent to the user. |
<b>Returns:</b>
Promise<[ActionCodeInfo](./auth.actioncodeinfo.md#actioncodeinfo_interface)<!-- -->>
metadata about the code.
## confirmPasswordReset()
Completes the password reset process, given a confirmation code and new password.
<b>Signature:</b>
```typescript
export declare function confirmPasswordReset(auth: Auth, oobCode: string, newPassword: string): Promise<void>;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| oobCode | string | A confirmation code sent to the user. |
| newPassword | string | The new password. |
<b>Returns:</b>
Promise<void>
## connectAuthEmulator()
Changes the [Auth](./auth.auth.md#auth_interface) instance to communicate with the Firebase Auth Emulator, instead of production Firebase Auth services.
This must be called synchronously immediately following the first call to [initializeAuth()](./auth.md#initializeauth)<!-- -->. Do not use with production credentials as emulator traffic is not encrypted.
<b>Signature:</b>
```typescript
export declare function connectAuthEmulator(auth: Auth, url: string, options?: {
disableWarnings: boolean;
}): void;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| url | string | The URL at which the emulator is running (eg, 'http://localhost:9099'). |
| options | { disableWarnings: boolean; } | Optional. <code>options.disableWarnings</code> defaults to <code>false</code>. Set it to <code>true</code> to disable the warning banner attached to the DOM. |
<b>Returns:</b>
void
### Example
```javascript
connectAuthEmulator(auth, 'http://127.0.0.1:9099', { disableWarnings: true });
```
## createUserWithEmailAndPassword()
Creates a new user account associated with the specified email address and password.
On successful creation of the user account, this user will also be signed in to your application.
User account creation can fail if the account already exists or the password is invalid.
Note: The email address acts as a unique identifier for the user and enables an email-based password reset. This function will create a new user account and set the initial user password.
<b>Signature:</b>
```typescript
export declare function createUserWithEmailAndPassword(auth: Auth, email: string, password: string): Promise<UserCredential>;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| email | string | The user's email address. |
| password | string | The user's chosen password. |
<b>Returns:</b>
Promise<[UserCredential](./auth.usercredential.md#usercredential_interface)<!-- -->>
## fetchSignInMethodsForEmail()
Gets the list of possible sign in methods for the given email address. This method returns an empty list when \[Email Enumeration Protection\](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled, irrespective of the number of authentication methods available for the given email.
This is useful to differentiate methods of sign-in for the same provider, eg. [EmailAuthProvider](./auth.emailauthprovider.md#emailauthprovider_class) which has 2 methods of sign-in, [SignInMethod](./auth.md#signinmethod)<!-- -->.EMAIL\_PASSWORD and [SignInMethod](./auth.md#signinmethod)<!-- -->.EMAIL\_LINK.
<b>Signature:</b>
```typescript
export declare function fetchSignInMethodsForEmail(auth: Auth, email: string): Promise<string[]>;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| email | string | The user's email address.<!-- -->Deprecated. Migrating off of this method is recommended as a security best-practice. Learn more in the Identity Platform documentation for \[Email Enumeration Protection\](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection). |
<b>Returns:</b>
Promise<string\[\]>
## getMultiFactorResolver()
Provides a [MultiFactorResolver](./auth.multifactorresolver.md#multifactorresolver_interface) suitable for completion of a multi-factor flow.
<b>Signature:</b>
```typescript
export declare function getMultiFactorResolver(auth: Auth, error: MultiFactorError): MultiFactorResolver;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| error | [MultiFactorError](./auth.multifactorerror.md#multifactorerror_interface) | The [MultiFactorError](./auth.multifactorerror.md#multifactorerror_interface) raised during a sign-in, or reauthentication operation. |
<b>Returns:</b>
[MultiFactorResolver](./auth.multifactorresolver.md#multifactorresolver_interface)
## getRedirectResult()
Returns a [UserCredential](./auth.usercredential.md#usercredential_interface) from the redirect-based sign-in flow.
If sign-in succeeded, returns the signed in user. If sign-in was unsuccessful, fails with an error. If no redirect operation was called, returns `null`<!-- -->.
This method does not work in a Node.js environment.
<b>Signature:</b>
```typescript
export declare function getRedirectResult(auth: Auth, resolver?: PopupRedirectResolver): Promise<UserCredential | null>;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| resolver | [PopupRedirectResolver](./auth.popupredirectresolver.md#popupredirectresolver_interface) | An instance of [PopupRedirectResolver](./auth.popupredirectresolver.md#popupredirectresolver_interface)<!-- -->, optional if already supplied to [initializeAuth()](./auth.md#initializeauth) or provided by [getAuth()](./auth.md#getauth)<!-- -->. |
<b>Returns:</b>
Promise<[UserCredential](./auth.usercredential.md#usercredential_interface) \| null>
### Example
```javascript
// Sign in using a redirect.
const provider = new FacebookAuthProvider();
// You can add additional scopes to the provider:
provider.addScope('user_birthday');
// Start a sign in process for an unauthenticated user.
await signInWithRedirect(auth, provider);
// This will trigger a full page redirect away from your app
// After returning from the redirect when your app initializes you can obtain the result
const result = await getRedirectResult(auth);
if (result) {
// This is the signed-in user
const user = result.user;
// This gives you a Facebook Access Token.
const credential = provider.credentialFromResult(auth, result);
const token = credential.accessToken;
}
// As this API can be used for sign-in, linking and reauthentication,
// check the operationType to determine what triggered this redirect
// operation.
const operationType = result.operationType;
```
## initializeRecaptchaConfig()
Loads the reCAPTCHA configuration into the `Auth` instance.
This will load the reCAPTCHA config, which indicates whether the reCAPTCHA verification flow should be triggered for each auth provider, into the current Auth session.
If initializeRecaptchaConfig() is not invoked, the auth flow will always start without reCAPTCHA verification. If the provider is configured to require reCAPTCHA verification, the SDK will transparently load the reCAPTCHA config and restart the auth flows.
Thus, by calling this optional method, you will reduce the latency of future auth flows. Loading the reCAPTCHA config early will also enhance the signal collected by reCAPTCHA.
This method does not work in a Node.js environment.
<b>Signature:</b>
```typescript
export declare function initializeRecaptchaConfig(auth: Auth): Promise<void>;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
<b>Returns:</b>
Promise<void>
### Example
```javascript
initializeRecaptchaConfig(auth);
```
## isSignInWithEmailLink()
Checks if an incoming link is a sign-in with email link suitable for [signInWithEmailLink()](./auth.md#signinwithemaillink)<!-- -->.
<b>Signature:</b>
```typescript
export declare function isSignInWithEmailLink(auth: Auth, emailLink: string): boolean;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| emailLink | string | The link sent to the user's email address. |
<b>Returns:</b>
boolean
## onAuthStateChanged()
Adds an observer for changes to the user's sign-in state.
To keep the old behavior, see [onIdTokenChanged()](./auth.md#onidtokenchanged)<!-- -->.
<b>Signature:</b>
```typescript
export declare function onAuthStateChanged(auth: Auth, nextOrObserver: NextOrObserver<User>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| nextOrObserver | [NextOrObserver](./auth.md#nextorobserver)<!-- --><[User](./auth.user.md#user_interface)<!-- -->> | callback triggered on change. |
| error | [ErrorFn](./util.md#errorfn) | Deprecated. This callback is never triggered. Errors on signing in/out can be caught in promises returned from sign-in/sign-out functions. |
| completed | [CompleteFn](./util.md#completefn) | Deprecated. This callback is never triggered. |
<b>Returns:</b>
[Unsubscribe](./util.md#unsubscribe)
## onIdTokenChanged()
Adds an observer for changes to the signed-in user's ID token.
This includes sign-in, sign-out, and token refresh events. This will not be triggered automatically upon ID token expiration. Use [User.getIdToken()](./auth.user.md#usergetidtoken) to refresh the ID token.
<b>Signature:</b>
```typescript
export declare function onIdTokenChanged(auth: Auth, nextOrObserver: NextOrObserver<User>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| nextOrObserver | [NextOrObserver](./auth.md#nextorobserver)<!-- --><[User](./auth.user.md#user_interface)<!-- -->> | callback triggered on change. |
| error | [ErrorFn](./util.md#errorfn) | Deprecated. This callback is never triggered. Errors on signing in/out can be caught in promises returned from sign-in/sign-out functions. |
| completed | [CompleteFn](./util.md#completefn) | Deprecated. This callback is never triggered. |
<b>Returns:</b>
[Unsubscribe](./util.md#unsubscribe)
## revokeAccessToken()
Revokes the given access token. Currently only supports Apple OAuth access tokens.
<b>Signature:</b>
```typescript
export declare function revokeAccessToken(auth: Auth, token: string): Promise<void>;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| token | string | The Apple OAuth access token. |
<b>Returns:</b>
Promise<void>
## sendPasswordResetEmail()
Sends a password reset email to the given email address. This method does not throw an error when there's no user account with the given email address and \[Email Enumeration Protection\](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled.
To complete the password reset, call [confirmPasswordReset()](./auth.md#confirmpasswordreset) with the code supplied in the email sent to the user, along with the new password specified by the user.
<b>Signature:</b>
```typescript
export declare function sendPasswordResetEmail(auth: Auth, email: string, actionCodeSettings?: ActionCodeSettings): Promise<void>;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| email | string | The user's email address. |
| actionCodeSettings | [ActionCodeSettings](./auth.actioncodesettings.md#actioncodesettings_interface) | The [ActionCodeSettings](./auth.actioncodesettings.md#actioncodesettings_interface)<!-- -->. |
<b>Returns:</b>
Promise<void>
### Example
```javascript
const actionCodeSettings = {
url: 'https://www.example.com/?email=user@example.com',
iOS: {
bundleId: 'com.example.ios'
},
android: {
packageName: 'com.example.android',
installApp: true,
minimumVersion: '12'
},
handleCodeInApp: true
};
await sendPasswordResetEmail(auth, 'user@example.com', actionCodeSettings);
// Obtain code from user.
await confirmPasswordReset('user@example.com', code);
```
## sendSignInLinkToEmail()
Sends a sign-in email link to the user with the specified email.
The sign-in operation has to always be completed in the app unlike other out of band email actions (password reset and email verifications). This is because, at the end of the flow, the user is expected to be signed in and their Auth state persisted within the app.
To complete sign in with the email link, call [signInWithEmailLink()](./auth.md#signinwithemaillink) with the email address and the email link supplied in the email sent to the user.
<b>Signature:</b>
```typescript
export declare function sendSignInLinkToEmail(auth: Auth, email: string, actionCodeSettings: ActionCodeSettings): Promise<void>;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | |
| email | string | The user's email address. |
| actionCodeSettings | [ActionCodeSettings](./auth.actioncodesettings.md#actioncodesettings_interface) | The [ActionCodeSettings](./auth.actioncodesettings.md#actioncodesettings_interface)<!-- -->. |
<b>Returns:</b>
Promise<void>
### Example
```javascript
const actionCodeSettings = {
url: 'https://www.example.com/?email=user@example.com',
iOS: {
bundleId: 'com.example.ios'
},
android: {
packageName: 'com.example.android',
installApp: true,
minimumVersion: '12'
},
handleCodeInApp: true
};
await sendSignInLinkToEmail(auth, 'user@example.com', actionCodeSettings);
// Obtain emailLink from the user.
if(isSignInWithEmailLink(auth, emailLink)) {
await signInWithEmailLink(auth, 'user@example.com', emailLink);
}
```
## setPersistence()
Changes the type of persistence on the [Auth](./auth.auth.md#auth_interface) instance for the currently saved `Auth` session and applies this type of persistence for future sign-in requests, including sign-in with redirect requests.
This makes it easy for a user signing in to specify whether their session should be remembered or not. It also makes it easier to never persist the `Auth` state for applications that are shared by other users or have sensitive data.
This method does not work in a Node.js environment.
<b>Signature:</b>
```typescript
export declare function setPersistence(auth: Auth, persistence: Persistence): Promise<void>;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| persistence | [Persistence](./auth.persistence.md#persistence_interface) | The [Persistence](./auth.persistence.md#persistence_interface) to use. |
<b>Returns:</b>
Promise<void>
A `Promise` that resolves once the persistence change has completed
### Example
```javascript
setPersistence(auth, browserSessionPersistence);
```
## signInAnonymously()
Asynchronously signs in as an anonymous user.
If there is already an anonymous user signed in, that user will be returned; otherwise, a new anonymous user identity will be created and returned.
<b>Signature:</b>
```typescript
export declare function signInAnonymously(auth: Auth): Promise<UserCredential>;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
<b>Returns:</b>
Promise<[UserCredential](./auth.usercredential.md#usercredential_interface)<!-- -->>
## signInWithCredential()
Asynchronously signs in with the given credentials.
An [AuthProvider](./auth.authprovider.md#authprovider_interface) can be used to generate the credential.
<b>Signature:</b>
```typescript
export declare function signInWithCredential(auth: Auth, credential: AuthCredential): Promise<UserCredential>;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| credential | [AuthCredential](./auth.authcredential.md#authcredential_class) | The auth credential. |
<b>Returns:</b>
Promise<[UserCredential](./auth.usercredential.md#usercredential_interface)<!-- -->>
## signInWithCustomToken()
Asynchronously signs in using a custom token.
Custom tokens are used to integrate Firebase Auth with existing auth systems, and must be generated by an auth backend using the [createCustomToken](https://firebase.google.com/docs/reference/admin/node/admin.auth.Auth#createcustomtoken) method in the [Admin SDK](https://firebase.google.com/docs/auth/admin) .
Fails with an error if the token is invalid, expired, or not accepted by the Firebase Auth service.
<b>Signature:</b>
```typescript
export declare function signInWithCustomToken(auth: Auth, customToken: string): Promise<UserCredential>;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| customToken | string | The custom token to sign in with. |
<b>Returns:</b>
Promise<[UserCredential](./auth.usercredential.md#usercredential_interface)<!-- -->>
## signInWithEmailAndPassword()
Asynchronously signs in using an email and password.
Fails with an error if the email address and password do not match. When \[Email Enumeration Protection\](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled, this method fails with "auth/invalid-credential" in case of an invalid email/password.
Note: The user's password is NOT the password used to access the user's email account. The email address serves as a unique identifier for the user, and the password is used to access the user's account in your Firebase project. See also: [createUserWithEmailAndPassword()](./auth.md#createuserwithemailandpassword)<!-- -->.
<b>Signature:</b>
```typescript
export declare function signInWithEmailAndPassword(auth: Auth, email: string, password: string): Promise<UserCredential>;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| email | string | The users email address. |
| password | string | The users password. |
<b>Returns:</b>
Promise<[UserCredential](./auth.usercredential.md#usercredential_interface)<!-- -->>
## signInWithEmailLink()
Asynchronously signs in using an email and sign-in email link.
If no link is passed, the link is inferred from the current URL.
Fails with an error if the email address is invalid or OTP in email link expires.
Note: Confirm the link is a sign-in email link before calling this method firebase.auth.Auth.isSignInWithEmailLink.
<b>Signature:</b>
```typescript
export declare function signInWithEmailLink(auth: Auth, email: string, emailLink?: string): Promise<UserCredential>;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| email | string | The user's email address. |
| emailLink | string | The link sent to the user's email address. |
<b>Returns:</b>
Promise<[UserCredential](./auth.usercredential.md#usercredential_interface)<!-- -->>
### Example
```javascript
const actionCodeSettings = {
url: 'https://www.example.com/?email=user@example.com',
iOS: {
bundleId: 'com.example.ios'
},
android: {
packageName: 'com.example.android',
installApp: true,
minimumVersion: '12'
},
handleCodeInApp: true
};
await sendSignInLinkToEmail(auth, 'user@example.com', actionCodeSettings);
// Obtain emailLink from the user.
if(isSignInWithEmailLink(auth, emailLink)) {
await signInWithEmailLink(auth, 'user@example.com', emailLink);
}
```
## signInWithPhoneNumber()
Asynchronously signs in using a phone number.
This method sends a code via SMS to the given phone number, and returns a [ConfirmationResult](./auth.confirmationresult.md#confirmationresult_interface)<!-- -->. After the user provides the code sent to their phone, call [ConfirmationResult.confirm()](./auth.confirmationresult.md#confirmationresultconfirm) with the code to sign the user in.
For abuse prevention, this method also requires a [ApplicationVerifier](./auth.applicationverifier.md#applicationverifier_interface)<!-- -->. This SDK includes a reCAPTCHA-based implementation, [RecaptchaVerifier](./auth.recaptchaverifier.md#recaptchaverifier_class)<!-- -->. This function can work on other platforms that do not support the [RecaptchaVerifier](./auth.recaptchaverifier.md#recaptchaverifier_class) (like React Native), but you need to use a third-party [ApplicationVerifier](./auth.applicationverifier.md#applicationverifier_interface) implementation.
This method does not work in a Node.js environment.
<b>Signature:</b>
```typescript
export declare function signInWithPhoneNumber(auth: Auth, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| phoneNumber | string | The user's phone number in E.164 format (e.g. +16505550101). |
| appVerifier | [ApplicationVerifier](./auth.applicationverifier.md#applicationverifier_interface) | The [ApplicationVerifier](./auth.applicationverifier.md#applicationverifier_interface)<!-- -->. |
<b>Returns:</b>
Promise<[ConfirmationResult](./auth.confirmationresult.md#confirmationresult_interface)<!-- -->>
### Example
```javascript
// 'recaptcha-container' is the ID of an element in the DOM.
const applicationVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container');
const confirmationResult = await signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
// Obtain a verificationCode from the user.
const credential = await confirmationResult.confirm(verificationCode);
```
## signInWithPopup()
Authenticates a Firebase client using a popup-based OAuth authentication flow.
If succeeds, returns the signed in user along with the provider's credential. If sign in was unsuccessful, returns an error object containing additional information about the error.
This method does not work in a Node.js environment.
<b>Signature:</b>
```typescript
export declare function signInWithPopup(auth: Auth, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<UserCredential>;
```
### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
| provider | [AuthProvider](./auth.authprovider.md#authprovider_interface) | The provider to authenticate. The provider has to be an [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class)<!-- -->. Non-OAuth providers like [EmailAuthProvider](./auth.emailauthprovider.md#emailauthprovider_class) will throw an error. |
| resolver | [PopupRedirectResolver](./auth.popupredirectresolver.md#popupredirectresolver_interface) | An instance of [PopupRedirectResolver](./auth.popupredirectresolver.md#popupredirectresolver_interface)<!-- -->, optional if already supplied to [initializeAuth()](./auth.md#initializeauth) or provided by [getAuth()](./auth.md#getauth)<!-- -->. |
<b>Returns:</b>
Promise<[UserCredential](./auth.usercredential.md#usercredential_interface)<!-- -->>
### Example
```javascript
// Sign in using a popup.
const provider = new FacebookAuthProvider();
const result = await signInWithPopup(auth, provider);
// The signed-in user info.
const user = result.user;
// This gives you a Facebook Access Token.
const credential = provider.credentialFromResult(auth, result);
const token = credential.accessToken;
```
## signInWithRedirect()
Authenticates a Firebase client using a full-page redirect flow.
To handle the results and errors for this operation, refer to [getRedirectResult()](./auth.md#getredirectresult)<!-- -->. Follow the [best practices](https://firebase.google.com/docs/auth/web/redirect-best-practices) when using [signInWithRedirect()](./auth.md#signinwithredirect)<!-- -->.
This method does not work in a Node.js environment.
<b>Signature:</b>
```typescript
export declare function signInWithRedirect(auth: Auth, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<never>;
```
### Parameters
| Parameter | Type | Description |