cmd-johnson / deno-oauth2-client

Minimalistic OAuth 2.0 client for Deno.
MIT License
45 stars 9 forks source link

Handle non standard error response #19

Closed w3cj closed 1 year ago

w3cj commented 2 years ago

I was using this library to integrate with Twitch OAuth, and I ran into an issue where the Twitch Token API response was non standard and I had no way to debug the response body (the response.body property was already read and could not be cloned). This PR attaches the parsed body to the response object for easier debugging.

BTW for anyone else that comes across this error integrating Twitch OAuth, the fix was to include the clientId and clientSecret in the body of the token request (again, another non standard thing the twitch API is asking for):

strategy.code.getToken('some-url-here?code=code-value-here&scope=', {
  requestOptions: {
    body: {
      // twitch doesn't seem to support RFC6749..., so add the client_id and client_secret to the body
      client_id: "value-here",
      client_secret: "value-here",
    }
  }
});