willowtreeapps / sign-in-with-apple-button-android

An Android library for Sign In with Apple
MIT License
283 stars 68 forks source link

Suggestions for query parameters and handling response in detail #57

Open workspace opened 4 years ago

workspace commented 4 years ago

Apple's official documentation for other platforms

This PR contains three subjects.

Add id_token in response_type

For our service, we need id_token rather than authorization code. we found that official documentation said "id_token" can be one of parameter for "response_type". With this change, we can get code and token finally. I guess this addition will help other developers! (depending on their backend implementation)

Get user data from response

According to official documentation, user's data is returned with encoded json string in query parameter. So, I tried to parse this data in SignInWebViewClient. (There is some unexpected behavior that only first attempt returns data with query parameter)

(NEW) mockk : mocking library for kotlin

I added mockk, mocking library for kotlin. It is very useful and easy to make situation that we want to test. Maybe it is easy to understand my test implementation to verify specific situation!

erawhctim commented 4 years ago

@KiminRyu Does this implementation still work with the current version of Apple's webview? I've followed your setup here and can't get any sort of response within shouldOverrideUrlLoading if I use response_mode=form_post.

The only way I've found that works (as of today) is using response_mode=fragment and parsing the JWT token and code out of the fragment. However, that doesn't include any name information (only email) and the scope parameter must be omitted (otherwise the webview errors and tells you to use form_post instead).

workspace commented 4 years ago

@erawhctim Yes, it works. Check this video. device-2020-04-06-155838.zip

I think your problem may be related with sign in with apple configuration in itunes connects and your server.

erawhctim commented 4 years ago

Sorry, I should've specified my question: Does this implementation work in the webview locally only, without implementing the redirect URL? I'm not implementing the redirect on the server; only trying to find a client-side solution.