UNPKG

voluptasmollitia

Version:
77 lines (54 loc) 3.11 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@firebase/auth](./auth.md) &gt; [TwitterAuthProvider](./auth.twitterauthprovider.md) ## TwitterAuthProvider class Provider for generating an [OAuthCredential](./auth.oauthcredential.md) for [ProviderId.TWITTER](./auth.providerid.twitter.md)<!-- -->. <b>Signature:</b> ```typescript export declare class TwitterAuthProvider extends BaseOAuthProvider ``` <b>Extends:</b> BaseOAuthProvider ## Example 1 ```javascript // Sign in using a redirect. const provider = new TwitterAuthProvider(); // 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 Twitter Access Token and Secret. const credential = provider.credentialFromResult(auth, result); const token = credential.accessToken; const secret = credential.secret; } ``` ## Example 2 ```javascript // Sign in using a popup. const provider = new TwitterAuthProvider(); const result = await signInWithPopup(auth, provider); // The signed-in user info. const user = result.user; // This gives you a Twitter Access Token and Secret. const credential = provider.credentialFromResult(auth, result); const token = credential.accessToken; const secret = credential.secret; ``` ## Constructors | Constructor | Modifiers | Description | | --- | --- | --- | | [(constructor)()](./auth.twitterauthprovider._constructor_.md) | | Constructs a new instance of the <code>TwitterAuthProvider</code> class | ## Properties | Property | Modifiers | Type | Description | | --- | --- | --- | --- | | [PROVIDER\_ID](./auth.twitterauthprovider.provider_id.md) | <code>static</code> | (not declared) | Always set to [ProviderId.TWITTER](./auth.providerid.twitter.md)<!-- -->. | | [TWITTER\_SIGN\_IN\_METHOD](./auth.twitterauthprovider.twitter_sign_in_method.md) | <code>static</code> | (not declared) | Always set to [SignInMethod.TWITTER](./auth.signinmethod.twitter.md)<!-- -->. | ## Methods | Method | Modifiers | Description | | --- | --- | --- | | [credential(token, secret)](./auth.twitterauthprovider.credential.md) | <code>static</code> | Creates a credential for Twitter. | | [credentialFromError(error)](./auth.twitterauthprovider.credentialfromerror.md) | <code>static</code> | Used to extract the underlying [OAuthCredential](./auth.oauthcredential.md) from a [AuthError](./auth.autherror.md) which was thrown during a sign-in, link, or reauthenticate operation. | | [credentialFromResult(userCredential)](./auth.twitterauthprovider.credentialfromresult.md) | <code>static</code> | Used to extract the underlying [OAuthCredential](./auth.oauthcredential.md) from a [UserCredential](./auth.usercredential.md)<!-- -->. |