tpcofficial / big-oauth2

A OAuth2 module to easily allow you to integrate your applications authentication with 3rd party IdPs. Returns user data with minimal code to help you create and manage users in your databases!
GNU General Public License v3.0
3 stars 1 forks source link

[Bug] Async issue causing GitHub provider to not function as expected #31

Closed dudeisbrendan03 closed 3 years ago

dudeisbrendan03 commented 3 years ago

Describe the bug Line 80: this.libs.fetch - A call to the GitHub OAuth2 API to trade our authentication code for a bearer token while requestion a JSON response for the body (for easy parsing)

This issue lays inside providers/generic.js where for some reason .then(... attached to line 80 is not waiting for the request finish, this is causing there to be missing data. The only way I can get this to function as expected is to remove all .then() statements from the this.libs.fetch call and replace it with

.then(async res => console.log(await res.text()))

This has been the only way I have managed to receive the body.

The only problem with this is that it would cause the flow to be completely broken and leave an open request if we were to get a response from the API which was not OK (200-300), this is also damaging to other OAuth2 providers we have functioning.

I am unsure on the cause of the issue but I'm looking into a solution now.

generic.js will be reverted to it's prior functional state.

To Reproduce Steps to reproduce the behavior:

  1. Configure an express route pointing to a correctly configured GitHub provider
  2. Start the flow

Expected behavior Should wait for the response before entering .then(... statement

dudeisbrendan03 commented 3 years ago

Squashed in 94df5eee99c46c2081c4a9fdee799bd7fff288bd this also completes #25