Changed state and email fields to optional to match Apple's responses #432
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.