Closed intonarumori closed 3 months ago
@intonarumori Thanks for the thorough investigation.
Surely I was always testing with a state
parameter, so it might be that the types here are wrong.
I will verify this locally and if it fixes the state
-less and/or "second login" flow as you describe, will prepare a release ASAP.
Should we do the same for name.firstName and name.lastName?
I think that is already working fine because the whole name
object is optional, and thus won't error when this is omitted.
Just tested this on web without any requested scopes
(no name or mail), and without passing a nonce
or state
either.
Before (on master) it failed, and with this fix it worked fine.
So thanks a ton @intonarumori!
Should we improve the code in the catch block here so if parsing errors in the future arise we get more informative error messages and can fix them quicker?
Yes, that would be a great follow-up. The code should not assume that it's only that specific error type. Will have to check whether an is
check would work on there, and if it doesn't match forward the "raw" error.
In this PR we updated the model objects to match Apple's responses.
The Issue
We were getting errors with the library if we omitted the state parameter in our call to
getIDCredential
or we were hiding our email address in the Apple Sign-in dialog. The error was pretty obscure:What was actually happening
state
parameter when callinggetIDCredential
and then hid the email in the Apple Sign-in dialogstate
andemail
fields were omitted in the JS response from AppletoDart
here could not parse the JS object because thestate
andemail
fields were defined as required fields and not optionals inUserI
andAuthorizationI
SignInErrorI
hereThe solution
state
field has been updated to be optional:state
is defined as optional when callinggetIDCredential
here. When not passing it, Apple will omit it in their response, thus it should be an optional field onAuthorizationI
.email
field has been updated to optional: In various circumstances (ex. when the user uses Apple sign-in with their email hidden) this field might be omitted in the response from Apple. Thus this should also be defined as optional inUserI
.Couple of questions remain
name.firstName
andname.lastName
? So far we were not about to clear any of these fields so it seems they are always provided, however it's hard to know we really covered all edge cases.