MauriceConrad / iCloud-API

Node API for Apple's iCloud services
1.18k stars 97 forks source link

#Contacts.new - Invalid sync token #54

Open calvintwr opened 4 years ago

calvintwr commented 4 years ago

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.

ZiizouChrist commented 3 years ago

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

calvintwr commented 3 years ago

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

ZiizouChrist commented 3 years ago

Hi @calvintwr, thanks for your help.

https://gist.github.com/ZiizouChrist/eb10605a186e1ab23d03b814b4bfc442

ZiizouChrist commented 3 years ago

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

calvintwr commented 3 years ago

@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

ZiizouChrist commented 3 years ago

@calvintwr Thanks for your help. Unfortunatly, the token error issue is still here.

Contacts.list works fine but I can't use #Contacts.new.

calvintwr commented 3 years ago

@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.

ZiizouChrist commented 3 years ago

@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.

calvintwr commented 3 years ago

There isn’t an official way — that’s the problem 😅.

On Wed, 7 Jul 2021 at 5:03 PM, ZizouChrist @.***> wrote:

@calvintwr https://github.com/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.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MauriceConrad/iCloud-API/issues/54#issuecomment-875427813, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABUCKPIGIANFI24HFZ7C6HLTWQJ7VANCNFSM4SVGCUSA .

ZiizouChrist commented 3 years ago

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