Add getTokenRequestWithAuthCodeFlow API for completing OAuth server-side #144
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.
Certain Oauth providers like https://developers.facebook.com/docs/instagram-basic-display-api/getting-started among others require that a client secret be included in the Oauth handoff to exchange the auth code for the access token. This library supports passing a client secret, but client secrets are fundamentally unsafe on mobile clients as described here: https://developer.okta.com/blog/2019/01/22/oauth-api-keys-arent-safe-in-mobile-apps and a PKCE flow should be used.
Since some Oauth providers are slow to adopt PKCE support, instead what we can do is support going through the Oauth redirect handoff on the client, receiving the auth code and then sending that data to a secure server which can then finish the Oauth flow and retrieve the access token using the client secret.
This change adds support for a
getTokenRequestWithAuthCodeFlow
API which goes through that process and returns all the data your server will need to complete the flow.Let me know if that makes sense and if there are any fundamental security or implementation issues with this approach and I'm happy to iterate on it.
Thanks.