4

ここでは、私は私のユーザーがCognitoに署名するのに使用したコードです(私は正しいと思います)。さて、私はどのようにサインアウトするのですか?現在、私は自分のサインアッププロセスを持っています(つまりFacebookやGoogleはまだありません)。aws cognitoからログアウトする方法 - アンドロイド?

// Callback handler for the sign-in process 
    private AuthenticationHandler authenticationHandler = new AuthenticationHandler() 
    { 
     @Override 
     public void onSuccess(CognitoUserSession userSession, CognitoDevice newDevice) 
     { 
      Log.d(COGNITO_LOGIN,"Login success!"); 
      cognitoUser.getDetailsInBackground(getDetailsHandler); 
      //Now we get user from dynamoDB and store it into a local user object. 
     } 
     @Override 
     public void getAuthenticationDetails(AuthenticationContinuation authenticationContinuation, String userId) 
     { 
      Log.d(COGNITO_LOGIN,passwordET.getText().toString()); 
      // The API needs user sign-in credentials to continue 
      AuthenticationDetails authenticationDetails = new AuthenticationDetails(userId, passwordET.getText().toString(), null); 

      // Pass the user sign-in credentials to the continuation 
      authenticationContinuation.setAuthenticationDetails(authenticationDetails); 

      // Allow the sign-in to continue 
      authenticationContinuation.continueTask(); 
     } 
     @Override 
     public void getMFACode(MultiFactorAuthenticationContinuation multiFactorAuthenticationContinuation) { 
      // Multi-factor authentication is required; get the verification code from user 
      multiFactorAuthenticationContinuation.setMfaCode("verificationCode"); 
      // Allow the sign-in process to continue 
      multiFactorAuthenticationContinuation.continueTask(); 
     } 
     @Override 
     public void authenticationChallenge(ChallengeContinuation continuation) { 
     } 
     @Override 
     public void onFailure(Exception exception) 
     { 
      // Sign-in failed, check exception for the cause 
      Log.d(COGNITO_LOGIN,"Login failed!"); 
      Log.d(COGNITO_LOGIN,exception.getMessage()); 
     } 
    }; 
cognitoUser.getSessionInBackground(authenticationHandler); 

答えて

0

ワイプまたは現在ログインしているユーザーのセッションをクリアする方法があり、次は私がこれまでに見つかった方法、です。

This is for fb in federated identities 
    if (fbAccessToken != null) { 
            LoginManager.getInstance().logOut(); 
           } 
This is for twiiter 
           if (mAuthManager != null) { 
             mAuthManager.clearAuthorizationState(null); 
           } 

           // wipe data 
           CognitoSyncClientManager.getInstance() 
             .wipeData(); 
0

以下のようなcognitoUserオブジェクトでsignOutを呼び出すだけでよいはずです。それは、デバイスからの明白なアクセス、ID、およびリフレッシュトークンなので、再度認証する必要があります。

// This has cleared all tokens and this user will have to go through the authentication process to get tokens. 
user.signOut(); 

トークンサーバー側を無効にするglobalSignOut呼び出しもあります。

+1

ユーザーが現在ログインしているかどうかを確認する方法はありますか?たとえば、[ログイン]または[ログアウト]ボタンを表示することを決定するにはどうすればよいですか? –

関連する問題