Skip to content

Commit

Permalink
Fix for Reddit Authentication (#866)
Browse files Browse the repository at this point in the history
* Fixed Reddit Authentication

* updated fix for build test

* updated buffer to avoid deprecation message

* Updated for passing tests
  • Loading branch information
afoyer committed Dec 6, 2020
1 parent 93f4dc0 commit 06a160a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/server/lib/oauth/callback.js
Expand Up @@ -210,10 +210,12 @@ async function _getOAuthAccessToken (code, provider, callback) {
if (!params.redirect_uri) { params.redirect_uri = provider.callbackUrl }

if (!headers['Content-Type']) { headers['Content-Type'] = 'application/x-www-form-urlencoded' }

// Added as a fix to accomodate change in Twitch oAuth API
if (!headers['Client-ID']) { headers['Client-ID'] = provider.clientId }

// Added as a fix for Reddit Authentication
if (provider.id === 'reddit') {
headers.Authorization = 'Basic ' + Buffer.from((provider.clientId + ':' + provider.clientSecret)).toString('base64')
}
// Okta errors when this is set. Maybe there are other Providers that also wont like this.
if (setGetAccessTokenAuthHeader) {
if (!headers.Authorization) { headers.Authorization = `Bearer ${code}` }
Expand Down

0 comments on commit 06a160a

Please sign in to comment.