However, if you need to access them in relation to working with an API outside Amplify or want access to AWS specific identifying information (e.g. IdentityId), you can access these implementation details by casting the result of fetchAuthSession as follows: ```java Amplify.Auth.fetchAuthSession( result -> { AWSCognitoAuthSession cognitoAuthSession = (AWSCognitoAuthSession) result; switch(cognitoAuthSession.getIdentityIdResult().getType()) { case SUCCESS: Log.i("AuthQuickStart", "IdentityId: " + cognitoAuthSession.getIdentityIdResult().getValue()); break; case FAILURE: Log.i("AuthQuickStart", "IdentityId not present because: " + cognitoAuthSession.getIdentityIdResult().getError().toString()); } }, error -> Log.e("AuthQuickStart", error.toString()) ); ``` ```kotlin Amplify.Auth.fetchAuthSession( { val session = it as AWSCognitoAuthSession when (session.identityIdResult.type) { AuthSessionResult.Type.SUCCESS -> Log.i("AuthQuickStart", "IdentityId = ${session.identityIdResult.value}") AuthSessionResult.Type.FAILURE -> Log.w("AuthQuickStart", "IdentityId not found", session.identityIdResult.error) } }, { Log.e("AuthQuickStart", "Failed to fetch session", it) } ) ``` ```kotlin try { val session = Amplify.Auth.fetchAuthSession() as AWSCognitoAuthSession val id = session.identityIdResult if (id.type == AuthSessionResult.Type.SUCCESS) { Log.i("AuthQuickStart", "IdentityId: ${id.value}") } else if (id.type == AuthSessionResult.Type.FAILURE) { Log.i("AuthQuickStart", "IdentityId not present: ${id.error}") } } catch (error: AuthException) { Log.e("AuthQuickStart", "Failed to fetch session", error) } ``` ```java RxAmplify.Auth.fetchAuthSession() .subscribe( result -> { AWSCognitoAuthSession cognitoAuthSession = (AWSCognitoAuthSession) result; switch (cognitoAuthSession.getIdentityIdResult().getType()) { case SUCCESS: Log.i("AuthQuickStart", "IdentityId: " + cognitoAuthSession.getIdentityIdResult().getValue()); break; case FAILURE: Log.i("AuthQuickStart", "IdentityId not present because: " + cognitoAuthSession.getIdentityIdResult().getError().toString()); } }, error -> Log.e("AuthQuickStart", error.toString()) ); ``` ## Force refreshing session You can ask the plugin to force refresh the internal session by setting the `forceRefresh` option when calling the fetchAuthSession API. ```java AuthFetchSessionOptions options = AuthFetchSessionOptions.builder().forceRefresh(true).build(); ``` ```kotlin val option = AuthFetchSessionOptions.builder().forceRefresh(true).build() ``` ```kotlin val option = AuthFetchSessionOptions.builder().forceRefresh(true).build() ``` ```java AuthFetchSessionOptions options = AuthFetchSessionOptions.builder().forceRefresh(true).build(); ```