TwitterAuthProvider class

ProviderIdOAuthCredentialを生成するプロバイダー。ツイッター。

サイン:

export declare class TwitterAuthProvider extends BaseOAuthProvider 

拡張: BaseOAuthProvider

コンストラクター

コンストラクタ修飾子説明
(コンストラクタ)() TwitterAuthProviderクラスの新しいインスタンスを構築します

プロパティ

財産修飾子タイプ説明
プロバイダーID static 「ツイッター.com」常にProviderIdに設定します。ツイッター。
TWITTER_SIGN_IN_METHOD static 「ツイッター.com」常にSignInMethodに設定します。ツイッター。

メソッド

方法修飾子説明
資格情報(トークン、シークレット) static Twitter の認証情報を作成します。
credentialFromError(エラー) staticサインイン、リンク、または再認証操作中にスローされたAuthErrorから基になるOAuthCredentialを抽出するために使用されます。
credentialFromResult(userCredential) static UserCredentialから基礎となるOAuthCredentialを抽出するために使用されます

TwitterAuthProvider.(コンストラクター)

TwitterAuthProviderクラスの新しいインスタンスを構築します

サイン:

constructor();

TwitterAuthProvider.PROVIDER_ID

常にProviderIdに設定します。ツイッター。

サイン:

static readonly PROVIDER_ID: 'twitter.com';

TwitterAuthProvider.TWITTER_SIGN_IN_METHOD

常にSignInMethodに設定します。ツイッター。

サイン:

static readonly TWITTER_SIGN_IN_METHOD: 'twitter.com';

TwitterAuthProvider.credential()

Twitter の認証情報を作成します。

サイン:

static credential(token: string, secret: string): OAuthCredential;

パラメーター

パラメータタイプ説明
トークンTwitterのアクセストークン。
秘密ツイッターの秘密。

戻り値:

OAuth認証情報

TwitterAuthProvider.credentialFromError()

サインイン、リンク、または再認証操作中にスローされたAuthErrorから基になるOAuthCredentialを抽出するために使用されます。

サイン:

static credentialFromError(error: FirebaseError): OAuthCredential | null;

パラメーター

パラメータタイプ説明
エラーFirebaseError

戻り値:

OAuth認証情報|ヌル

TwitterAuthProvider.credentialFromResult()

UserCredentialから基礎となるOAuthCredentialを抽出するために使用されます

サイン:

static credentialFromResult(userCredential: UserCredential): OAuthCredential | null;

パラメーター

パラメータタイプ説明
ユーザー資格情報ユーザー資格情報ユーザーの資格情報。

戻り値:

OAuth認証情報|ヌル

例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 = TwitterAuthProvider.credentialFromResult(result);
  const token = credential.accessToken;
  const secret = credential.secret;
}

例 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 = TwitterAuthProvider.credentialFromResult(result);
const token = credential.accessToken;
const secret = credential.secret;