signInWithApple method
Implementation
@override
Future<Response<Credential>> signInWithApple() async {
final response = Response<Credential>();
try {
final result = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
);
if (result.identityToken != null) {
final credential = OAuthProvider("apple.com").credential(
idToken: result.identityToken,
accessToken: result.authorizationCode,
);
return response.withData(Credential(
credential: credential,
accessToken: result.authorizationCode,
idToken: result.identityToken,
id: result.userIdentifier,
email: result.email,
name: result.givenName ?? result.familyName,
));
} else {
return response.withException('Token not valid!', status: Status.error);
}
} on SignInWithAppleAuthorizationException catch (_) {
return response.withException(_.message, status: Status.failure);
}
}