adambrgmn / react-oauth-flow

An OAuth2 flow for React apps
MIT License
94 stars 37 forks source link

Enhancement/custom token fetch fn #29

Closed aguscha333 closed 6 years ago

aguscha333 commented 6 years ago

OauthReceiver allow custom fetch function

This PR fixes #28. It contains an enhancement to the OauthReceiver component. The aim is to allow the use of a custom fetch function since the one being used had some restrictions.

Added tokenFn as an optional prop to the OauthReceiver. As it says in the new documentation it should be a Promise, if it's a function then it will be used as fetch, if not it will fall back to the fetch2 function that was originally being used.

The tokenFn receives the same props as fetch2. I don't think that fetchTokenArgs is needed in this case since tokenFn will probably already have the correct configuration for the project. I kept it just in case someone needs it.

Documentation was edited to include this new enhancement and tests were added as well.

All tests are passing and I tested it in my own project and is working as well.

I am not an expert when writing tests so I'd appreciate any feedback on those and on the other changes as well.

If there is anything else I need to do in order to get this approved please let me know.

adambrgmn commented 6 years ago

Hi, @aguscha333, Sorry I haven't responded yet. But I have a very busy work week right now. But I'll look into this in the beginning of next week!

aguscha333 commented 6 years ago

hi @adambrgmn, Sure! no worries 😄.

adambrgmn commented 6 years ago

@aguscha333 , great work! I like the implementation and it works fine for me as well! I'll merge this :)

adambrgmn commented 6 years ago

:tada: This PR is included in version 1.2.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: