2021年2月10日星期三

Issue with Sign In With Apple - unable to retrieve name and email

I used sample code from Apple's Juice example application to implement SIWA. But it returns nil for both name and email. To delete any previously saved credentials, I used this code:

    static func deleteUserIdentifierFromKeychain() {          do {              try KeychainItem(service: "app.bundle.ID", account: "userIdentifier").deleteItem()          } catch {              print("Unable to delete userIdentifier from keychain")          }      }  

Then ran this code to request scope with full name and email scopes:

let request = ASAuthorizationAppleIDProvider().createRequest()          request.requestedScopes = [.fullName, .email]          let controller = ASAuthorizationController(authorizationRequests: [request])          controller.delegate = self          controller.presentationContextProvider = self          controller.performRequests()  

When I read the return values from ASAuthorizationAppleIDCredential, I get nil and nil. I do get a user identifier but no name or email.

func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {          switch authorization.credential {          case let appleIDCredential as ASAuthorizationAppleIDCredential:                let userIdentifier = appleIDCredential.user              let fullName = appleIDCredential.fullName              let appleEmail = appleIDCredential.email  

What am I doing wrong?

https://stackoverflow.com/questions/66147801/issue-with-sign-in-with-apple-unable-to-retrieve-name-and-email February 11, 2021 at 10:05AM

没有评论:

发表评论