The Firebase JS SDK is now in BETA!
This EAP site is no longer maintained. See the official Firebase Documentation site for the latest documentation and information about the Firebase JS SDK.

Home > @firebase/auth > TwitterAuthProvider

TwitterAuthProvider class

Provider for generating an OAuthCredential for ProviderId.TWITTER.

Signature:

export declare class TwitterAuthProvider extends BaseOAuthProvider 

Extends: BaseOAuthProvider

Example 1

// 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

// 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)() Constructs a new instance of the TwitterAuthProvider class

Properties

Property Modifiers Type Description
PROVIDER_ID static (not declared) Always set to ProviderId.TWITTER.
TWITTER_SIGN_IN_METHOD static (not declared) Always set to SignInMethod.TWITTER.

Methods

Method Modifiers Description
credential(token, secret) static Creates a credential for Twitter.
credentialFromError(error) static Used to extract the underlying OAuthCredential from a AuthError which was thrown during a sign-in, link, or reauthenticate operation.
credentialFromResult(userCredential) static Used to extract the underlying OAuthCredential from a UserCredential.