FacebookAuthProvider class Stay organized with collections Save and categorize content based on your preferences.
Provider for generating anOAuthCredential forProviderId.FACEBOOK.
Signature:
exportdeclareclassFacebookAuthProviderextendsBaseOAuthProviderExtends: BaseOAuthProvider
Constructors
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)() | Constructs a new instance of theFacebookAuthProvider class |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| FACEBOOK_SIGN_IN_METHOD | static | 'facebook.com' | Always set toSignInMethod.FACEBOOK. |
| PROVIDER_ID | static | 'facebook.com' | Always set toProviderId.FACEBOOK. |
Methods
| Method | Modifiers | Description |
|---|---|---|
| credential(accessToken) | static | Creates a credential for Facebook. |
| credentialFromError(error) | static | Used to extract the underlyingOAuthCredential from aAuthError which was thrown during a sign-in, link, or reauthenticate operation. |
| credentialFromResult(userCredential) | static | Used to extract the underlyingOAuthCredential from aUserCredential. |
FacebookAuthProvider.(constructor)
Constructs a new instance of theFacebookAuthProvider class
Signature:
constructor();FacebookAuthProvider.FACEBOOK_SIGN_IN_METHOD
Always set toSignInMethod.FACEBOOK.
Signature:
staticreadonlyFACEBOOK_SIGN_IN_METHOD:'facebook.com';FacebookAuthProvider.PROVIDER_ID
Always set toProviderId.FACEBOOK.
Signature:
staticreadonlyPROVIDER_ID:'facebook.com';FacebookAuthProvider.credential()
Creates a credential for Facebook.
Signature:
staticcredential(accessToken:string):OAuthCredential;Parameters
| Parameter | Type | Description |
|---|---|---|
| accessToken | string | Facebook access token. |
Returns:
Example
// `event` from the Facebook auth.authResponseChange callback.constcredential=FacebookAuthProvider.credential(event.authResponse.accessToken);constresult=awaitsignInWithCredential(credential);FacebookAuthProvider.credentialFromError()
Used to extract the underlyingOAuthCredential from aAuthError which was thrown during a sign-in, link, or reauthenticate operation.
Signature:
staticcredentialFromError(error:FirebaseError):OAuthCredential|null;Parameters
| Parameter | Type | Description |
|---|---|---|
| error | FirebaseError |
Returns:
OAuthCredential | null
FacebookAuthProvider.credentialFromResult()
Used to extract the underlyingOAuthCredential from aUserCredential.
Signature:
staticcredentialFromResult(userCredential:UserCredential):OAuthCredential|null;Parameters
| Parameter | Type | Description |
|---|---|---|
| userCredential | UserCredential | The user credential. |
Returns:
OAuthCredential | null
Example 1
// Sign in using a redirect.constprovider=newFacebookAuthProvider();// Start a sign in process for an unauthenticated user.provider.addScope('user_birthday');awaitsignInWithRedirect(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 resultconstresult=awaitgetRedirectResult(auth);if(result){// This is the signed-in userconstuser=result.user;// This gives you a Facebook Access Token.constcredential=FacebookAuthProvider.credentialFromResult(result);consttoken=credential.accessToken;}Example 2
// Sign in using a popup.constprovider=newFacebookAuthProvider();provider.addScope('user_birthday');constresult=awaitsignInWithPopup(auth,provider);// The signed-in user info.constuser=result.user;// This gives you a Facebook Access Token.constcredential=FacebookAuthProvider.credentialFromResult(result);consttoken=credential.accessToken;Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-01-19 UTC.