Skip to content

Latest commit

 

History

History
106 lines (70 loc) · 2.86 KB

_lib_index_d_.rnappleauth.appleautherror.md

File metadata and controls

106 lines (70 loc) · 2.86 KB

Enumeration: AppleAuthError

Errors that can occur during authorization.

url https://developer.apple.com/documentation/authenticationservices/asauthorizationerror/code

What is it?

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) {
    }
  }
}

Index

Enumeration members

Enumeration members

CANCELED

CANCELED: = "1001"

Defined in lib/index.d.ts:406

The user canceled the authorization attempt.


FAILED

FAILED: = "1004"

Defined in lib/index.d.ts:421

The authorization attempt failed.


INVALID_RESPONSE

INVALID_RESPONSE: = "1002"

Defined in lib/index.d.ts:411

The authorization request received an invalid response.


NOT_HANDLED

NOT_HANDLED: = "1003"

Defined in lib/index.d.ts:416

The authorization request wasn't handled.


UNKNOWN

UNKNOWN: = "1000"

Defined in lib/index.d.ts:401

The authorization attempt failed for an unknown reason.