Errors that can occur during authorization.
url
https://developer.apple.com/documentation/authenticationservices/asauthorizationerror/code
This is an exported member, AppleAuthError
from the react-native-apple-authentication
library. This is used to
check the error code after a appleAuth.getCredentialStateForUser(user)
request has been made.
import appleAuth, {
AppleAuthRequestOperation,
AppleAuthRequestScope,
AppleAuthCredentialState,
AppleAuthError,
} from '@invertase/react-native-apple-authentication';
async function onPressAppleButton() {
const requestOptions = {
requestedOperation: AppleAuthRequestOperation.LOGIN,
requestedScopes: [AppleAuthRequestScope.EMAIL, AppleAuthRequestScope.FULL_NAME],
};
const { user } = await appleAuth.performRequest(requestOptions);
try {
const credentialState = await appleAuth.getCredentialStateForUser(user);
if (credentialState === AppleAuthCredentialState.AUTHORIZED) {
// authorized
}
} catch (error) {
if (error.code === AppleAuthError.CANCELED) {
}
if (error.code === AppleAuthError.FAILED) {
}
if (error.code === AppleAuthError.INVALID_RESPONSE) {
}
if (error.code === AppleAuthError.NOT_HANDLED) {
}
if (error.code === AppleAuthError.UNKNOWN) {
}
}
}
• CANCELED: = "1001"
Defined in lib/index.d.ts:406
The user canceled the authorization attempt.
• FAILED: = "1004"
Defined in lib/index.d.ts:421
The authorization attempt failed.
• INVALID_RESPONSE: = "1002"
Defined in lib/index.d.ts:411
The authorization request received an invalid response.
• NOT_HANDLED: = "1003"
Defined in lib/index.d.ts:416
The authorization request wasn't handled.
• UNKNOWN: = "1000"
Defined in lib/index.d.ts:401
The authorization attempt failed for an unknown reason.