Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

サインアウト

Amplifyは、Amplify Authなどのバックエンドリソースと対話するためのクライアントライブラリを提供します。

フロントエンドアプリケーションでAmplify Authの使用を開始する最速の方法は、カスタマイズ可能なUIと完全な認証フローを提供するAuthenticatorコンポーネントです。

ユーザーをアプリケーションからサインアウトするには、signOut APIを使用します。

Future<void> signOutCurrentUser() async {
final result = await Amplify.Auth.signOut();
if (result is CognitoCompleteSignOut) {
safePrint('Sign out completed successfully');
} else if (result is CognitoFailedSignOut) {
safePrint('Error signing user out: ${result.exception.message}');
}
}

すべてのデバイスからユーザーをサインアウトするグローバルサインアウトを実行することもできます。これは、ユーザーに発行されたすべてのリフレッシュトークンも無効にします。ユーザーの現在のアクセストークンとIDトークンは、リフレッシュトークンの有効期限が切れるまで他のデバイスで有効なままです(アクセストークンとIDトークンは発行後1時間で期限切れになります)。

Future<void> signOutGlobally() async {
final result = await Amplify.Auth.signOut(
options: const SignOutOptions(globalSignOut: true),
);
if (result is CognitoCompleteSignOut) {
safePrint('Sign out completed successfully');
} else if (result is CognitoPartialSignOut) {
final globalSignOutException = result.globalSignOutException!;
final accessToken = globalSignOutException.accessToken;
// Retry the global sign out using the access token, if desired
// ...
safePrint('Error signing user out: ${globalSignOutException.message}');
} else if (result is CognitoFailedSignOut) {
safePrint('Error signing user out: ${result.exception.message}');
}
}