// Sign in using a redirect.constprovider=newTwitterAuthProvider();// Start a sign in process for an unauthenticated user.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 Twitter Access Token and Secret.constcredential=TwitterAuthProvider.credentialFromResult(result);consttoken=credential.accessToken;constsecret=credential.secret;}
Example 2
// Sign in using a popup.constprovider=newTwitterAuthProvider();constresult=awaitsignInWithPopup(auth,provider);// The signed-in user info.constuser=result.user;// This gives you a Twitter Access Token and Secret.constcredential=TwitterAuthProvider.credentialFromResult(result);consttoken=credential.accessToken;constsecret=credential.secret;
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-01-19 UTC."],[],[],null,["# TwitterAuthProvider class\n\nProvider for generating an [OAuthCredential](./auth.oauthcredential.md#oauthcredential_class) for [ProviderId](./auth.md#providerid).TWITTER.\n\n**Signature:** \n\n export declare class TwitterAuthProvider extends BaseOAuthProvider \n\n**Extends:** BaseOAuthProvider\n\nConstructors\n------------\n\n| Constructor | Modifiers | Description |\n|---------------------------------------------------------------------------------|-----------|--------------------------------------------------------------|\n| [(constructor)()](./auth.twitterauthprovider.md#twitterauthproviderconstructor) | | Constructs a new instance of the `TwitterAuthProvider` class |\n\nProperties\n----------\n\n| Property | Modifiers | Type | Description |\n|---------------------------------------------------------------------------------------------------|-----------|---------------|---------------------------------------------------------------|\n| [PROVIDER_ID](./auth.twitterauthprovider.md#twitterauthproviderprovider_id) | `static` | 'twitter.com' | Always set to [ProviderId](./auth.md#providerid).TWITTER. |\n| [TWITTER_SIGN_IN_METHOD](./auth.twitterauthprovider.md#twitterauthprovidertwitter_sign_in_method) | `static` | 'twitter.com' | Always set to [SignInMethod](./auth.md#signinmethod).TWITTER. |\n\nMethods\n-------\n\n| Method | Modifiers | Description |\n|---------------------------------------------------------------------------------------------------------------|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [credential(token, secret)](./auth.twitterauthprovider.md#twitterauthprovidercredential) | `static` | Creates a credential for Twitter. |\n| [credentialFromError(error)](./auth.twitterauthprovider.md#twitterauthprovidercredentialfromerror) | `static` | Used to extract the underlying [OAuthCredential](./auth.oauthcredential.md#oauthcredential_class) from a [AuthError](./auth.autherror.md#autherror_interface) which was thrown during a sign-in, link, or reauthenticate operation. |\n| [credentialFromResult(userCredential)](./auth.twitterauthprovider.md#twitterauthprovidercredentialfromresult) | `static` | Used to extract the underlying [OAuthCredential](./auth.oauthcredential.md#oauthcredential_class) from a [UserCredential](./auth.usercredential.md#usercredential_interface). |\n\nTwitterAuthProvider.(constructor)\n---------------------------------\n\nConstructs a new instance of the `TwitterAuthProvider` class\n\n**Signature:** \n\n constructor();\n\nTwitterAuthProvider.PROVIDER_ID\n-------------------------------\n\nAlways set to [ProviderId](./auth.md#providerid).TWITTER.\n\n**Signature:** \n\n static readonly PROVIDER_ID: 'twitter.com';\n\nTwitterAuthProvider.TWITTER_SIGN_IN_METHOD\n------------------------------------------\n\nAlways set to [SignInMethod](./auth.md#signinmethod).TWITTER.\n\n**Signature:** \n\n static readonly TWITTER_SIGN_IN_METHOD: 'twitter.com';\n\nTwitterAuthProvider.credential()\n--------------------------------\n\nCreates a credential for Twitter.\n\n**Signature:** \n\n static credential(token: string, secret: string): OAuthCredential;\n\n#### Parameters\n\n| Parameter | Type | Description |\n|-----------|--------|-----------------------|\n| token | string | Twitter access token. |\n| secret | string | Twitter secret. |\n\n**Returns:**\n\n[OAuthCredential](./auth.oauthcredential.md#oauthcredential_class)\n\nTwitterAuthProvider.credentialFromError()\n-----------------------------------------\n\nUsed to extract the underlying [OAuthCredential](./auth.oauthcredential.md#oauthcredential_class) from a [AuthError](./auth.autherror.md#autherror_interface) which was thrown during a sign-in, link, or reauthenticate operation.\n\n**Signature:** \n\n static credentialFromError(error: FirebaseError): OAuthCredential | null;\n\n#### Parameters\n\n| Parameter | Type | Description |\n|-----------|--------------------------------------------------------------|-------------|\n| error | [FirebaseError](./util.firebaseerror.md#firebaseerror_class) | |\n\n**Returns:**\n\n[OAuthCredential](./auth.oauthcredential.md#oauthcredential_class) \\| null\n\nTwitterAuthProvider.credentialFromResult()\n------------------------------------------\n\nUsed to extract the underlying [OAuthCredential](./auth.oauthcredential.md#oauthcredential_class) from a [UserCredential](./auth.usercredential.md#usercredential_interface).\n\n**Signature:** \n\n static credentialFromResult(userCredential: UserCredential): OAuthCredential | null;\n\n#### Parameters\n\n| Parameter | Type | Description |\n|----------------|---------------------------------------------------------------------|----------------------|\n| userCredential | [UserCredential](./auth.usercredential.md#usercredential_interface) | The user credential. |\n\n**Returns:**\n\n[OAuthCredential](./auth.oauthcredential.md#oauthcredential_class) \\| null\n\n### Example 1\n\n // Sign in using a redirect.\n const provider = new TwitterAuthProvider();\n // Start a sign in process for an unauthenticated user.\n await signInWithRedirect(auth, provider);\n // This will trigger a full page redirect away from your app\n\n // After returning from the redirect when your app initializes you can obtain the result\n const result = await getRedirectResult(auth);\n if (result) {\n // This is the signed-in user\n const user = result.user;\n // This gives you a Twitter Access Token and Secret.\n const credential = TwitterAuthProvider.credentialFromResult(result);\n const token = credential.accessToken;\n const secret = credential.secret;\n }\n\n### Example 2\n\n // Sign in using a popup.\n const provider = new TwitterAuthProvider();\n const result = await signInWithPopup(auth, provider);\n\n // The signed-in user info.\n const user = result.user;\n // This gives you a Twitter Access Token and Secret.\n const credential = TwitterAuthProvider.credentialFromResult(result);\n const token = credential.accessToken;\n const secret = credential.secret;"]]