How to handle the message "ACAccountCredentialRenewResultRejected" when calling renewCredentialsForAccount

I create an ACAccountStore , access my facebook user account, store the account in the ACAccount object ACAccount and can extract the token from the credentials. But when I try to use this token to retrieve information from Facebook, it will not be authenticated, and trying to renew credentials using renewCredentialsForAccount will just give ACAccountCredentialRenewResultRejected answer.

I cannot get a permission popup to reappear to request permission in any simple way. The only way to get him to request permission again is either to change the permissions that I request in the application, or to delete and re-add my facebook account in the settings.

How can I get a valid authorization token at this point?

+7
source share
1 answer

Since there is no answer, I am trying to answer what I found. After my comment above, I read the documentation for updateCredentialsForAccount, which says: "If the user has canceled the authorization of your application, this renewal request will return ACAccountCredentialRenewResultRejected."

Which means that this is not the user who rejects, but Facebook.

I think I understand the concept now, and I'm trying to answer those who have not dealt with this problem, like me. In fact, I did not understand that my FB token will be completely reset when I get the result ACAccountCredentialRenewResultRejected. And this is a key element in the puzzle.

So what you need to do for different results:

  • ACAccountCredentialRenewResultRenewed , you are good to go, and you have a new token. Go and run SLRequest with this updated token.
  • ACAccountCredentialRenewResultRejected : your token is reset , if you try to get it, it will be nil . You must request permission from users from scratch and “install” the application for Facebook. This means that you first request the usual "email permissions and other read permissions" and (if you need it) in a separate request requesting write permissions. (Someone can explain why Facebook wants me to bother the user twice if I want to upload a photo, for example)
  • ACAccountCredentialRenewResultFailed : I could not reproduce this ever. I believe that you are sending an error message to the user.

Here is what I came up with. This is a very nasty API that has poor documentation and missing samples. In addition, examples on the Internet relate to “success,” and they don’t care that the user can revoke permissions outside the application. I constantly try and cannot develop a development mode. Weakening gray hair, but coming to an end. Hope my answer helps others.

+3
source

All Articles