Skip to content

Commit 06a160a

Browse files
authored
Fix for Reddit Authentication (#866)
* Fixed Reddit Authentication * updated fix for build test * updated buffer to avoid deprecation message * Updated for passing tests
1 parent 93f4dc0 commit 06a160a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/server/lib/oauth/callback.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,12 @@ async function _getOAuthAccessToken (code, provider, callback) {
210210
if (!params.redirect_uri) { params.redirect_uri = provider.callbackUrl }
211211

212212
if (!headers['Content-Type']) { headers['Content-Type'] = 'application/x-www-form-urlencoded' }
213-
214213
// Added as a fix to accomodate change in Twitch oAuth API
215214
if (!headers['Client-ID']) { headers['Client-ID'] = provider.clientId }
216-
215+
// Added as a fix for Reddit Authentication
216+
if (provider.id === 'reddit') {
217+
headers.Authorization = 'Basic ' + Buffer.from((provider.clientId + ':' + provider.clientSecret)).toString('base64')
218+
}
217219
// Okta errors when this is set. Maybe there are other Providers that also wont like this.
218220
if (setGetAccessTokenAuthHeader) {
219221
if (!headers.Authorization) { headers.Authorization = `Bearer ${code}` }

0 commit comments

Comments
 (0)