MauriceConrad/iCloud-API

#Contacts.new - Invalid sync token

calvintwr opened this issue · 10 comments

When using #Contacts.new to add a new contact, I will get the following error message:

"requestUUID":"4758bb9d-c842-4efc-8c66-b6e3dc2d18e4","errorReason":"Invalid sync token","errorCode":420

Per documentation, I have used #Contacts.list prior before invoking #Contacts.new like this:

cloud.Contacts.list().then(data => {
     return cloud.Contacts.new(validData)
})

Assume that validData has valid data.

Hey @calvintwr, i'm just having the same invalid sync token issue.
#Contacts.new is working fine, but after few times (one hour), I got this invalid sync token error.
Maybe I have to refresh this sync token but i dont know how. I've tried to reset login but it didn't work.
Now, #Contacts.list works fine but #Contacts.new is broken for my Apple account.

How did you solve it ? Plz help me if you can.
Best Regards

Hi @ZiizouChrist can I see your code? Gist or repo is fine.

Hi @calvintwr,
have you got an insight about the way to solve the token error issue?
If you have any questions about my code please let me know
Thanks again

@ZiizouChrist I checked through your code and it seems alright, except the only difference with mine probably me calling #saveSession. Below is my gist:

(You can ignore the setInterval for re-authentication. It was previously coded like that when there's no 2FA set up, and I could have the session updated without any 2FA inputs).

https://gist.github.com/calvintwr/626d1812cf8a431349fe3070aac7bb89

@calvintwr Thanks for your help. Unfortunatly, the token error issue is still here.
#Contacts.list works fine but I can't use #Contacts.new.

@ZiizouChrist that's really odd. For me I use #Contacts.list as a check on whether the session is valid, and could always use #Contacts.new if #Contact.list works -- they work and fail together.

Actually, it might make sense to just use Google Contacts, given that this is not really an official mean to access iCloud contacts.

@calvintwr I assume that is very weird #Contacts.list works but #Contacts.new throws this invalid sync token error.
Like I said, if I use a new iCloud account, #Contacts.new works fine for multiples calls until I receive invalid sync token for ever.

I know this is an unofficial mean to access iCloud contacts. Can you tell me what is the official way please ?

Thanks a lot for your time.

Haha nice. Thanks again for your help. Have a good day.