```dart
Future<void> fetchAuthSession() async {
  try {
    final result = await Amplify.Auth.fetchAuthSession(
      options: CognitoSessionOptions(getAWSCredentials: true),
    );
    String identityId = (result as CognitoAuthSession).identityId!;
    safePrint('identityId: $identityId');
  } on AuthException catch (e) {
    safePrint(e.message);
  }
}
```

If the `getAWSCredentials` option is true, the result will contain AWS credentials and tokens.  If it is set to false, the result will contain a simple `isSignedIn` flag.

### Setting a timeout for fetchAuthSession

On spotty networks, the `fetchAuthSession` call can take upwards of a minute to either complete or fail due to internal retries. If this is too long, consider adding a custom timeout using the `timeout` function as shown in the below example.

```dart
Future<void> fetchAuthSessionWithTimeout() async {
  try {
    final result = await Amplify.Auth.fetchAuthSession().timeout(
      const Duration(seconds: 5),
    );
    final identityId = (result as CognitoAuthSession).identityId!;
    safePrint('identityId: $identityId');
  } on Exception catch (e) {
    safePrint('Something went wrong while fetching the session: $e');
  }
}
```
