getKeychainCredential method

  1. @override
Future<AuthorizationCredentialPassword> getKeychainCredential()
override

Implementation

@override
Future<AuthorizationCredentialPassword> getKeychainCredential() async {
  try {
    if (!Platform.isIOS &&
        !Platform.isMacOS &&
        Platform.environment['FLUTTER_TEST'] != 'true') {
      throw const SignInWithAppleNotSupportedException(
        message: 'The current platform is not supported',
      );
    }

    final response = await _channel.invokeMethod<Map<dynamic, dynamic>>(
      'performAuthorizationRequest',
      [
        const PasswordAuthorizationRequest(),
      ].map((request) => request.toJson()).toList(),
    );

    if (response == null) {
      throw Exception('getKeychainCredential: Received `null` response');
    }

    return parseAuthorizationCredentialPassword(response);
  } on PlatformException catch (exception) {
    throw SignInWithAppleException.fromPlatformException(exception);
  }
}