Failed token exchange when signing in with Apple on native iOS app

  • Auth0 iOS Swift SDK
  • version 1.22.1
  • iOS 13.2

Apple sign in is successful on Apple side, and the web app is working fine. The token exchange on iOS app fails with server error “Log in is temporarily unavailable. Please try again in a few minutes.”

Code used for token exchange:

guard let authorizationCode = credentials.authorizationCode,
        let authCode = String(data: authorizationCode, encoding: .utf8) else {
            callback?.onFailure(.invalidGrant)
            return
    }

    Auth0.authentication()
        .tokenExchange(withAppleAuthorizationCode: authCode,
                       fullName: credentials.fullName)
        .start { result in
            switch result {
            case .success(let auth0Credentials):
                if let credentials = self.convert(credentials: auth0Credentials) {
                    callback?.onSuccess(credentials)
                } else {
                    callback?.onFailure(.invalidGrant)
                }
            case .failure(let error):
                callback?.onFailure(.invalidGrant)
            }
    }