node-oauth icon indicating copy to clipboard operation
node-oauth copied to clipboard

Oauth2 with Reddit

Open henryfw opened this issue 10 years ago • 6 comments

I had to added the following after line 163 in oauth2.js (method getOAuthAccessToken) to get Reddit to work:

   'Authorization' : 'Basic ' + new Buffer(this._clientId + ':' + this._clientSecret).toString('base64') ,

This header addition did not seem to break Instagram or Google Oauth2.

henryfw avatar Jul 14 '14 07:07 henryfw

It doesn't break Facebook either.

nvrnight avatar Oct 30 '14 15:10 nvrnight

As per the RFC, Basic Auth is the recommended way. Is there any way of passing in an option to switch between Basic Auth and body passed params?

jnorberg avatar Apr 15 '15 06:04 jnorberg

Hit this same problem myself.

hiddentao avatar Mar 03 '16 01:03 hiddentao

My workaround is to pass custom headers as the last parameter to the OAuth2 constructor:

new OAuth2(..,..,. ...  { 'Authorization': 'Basic ZlZfTkdsY3NNNV' });

hiddentao avatar Mar 03 '16 02:03 hiddentao

You can override the prototype – a lot of Passport strategies are currently doing so and so is Reddit : https://github.com/Slotos/passport-reddit/blob/master/lib/passport-reddit/strategy.js --> see the comment

// Reddit token endpoint expects basic auth header "with the consumer key as the username
// and the consumer secret as the password". To comply we are resorting to overriding
// node-oauth's implmentation of getOAuthAccessToken().

sebilasse avatar May 24 '16 07:05 sebilasse

You can override the prototype – a lot of Passport strategies are currently doing so and so is Reddit : https://github.com/Slotos/passport-reddit/blob/master/lib/passport-reddit/strategy.js --> see the comment

// Reddit token endpoint expects basic auth header "with the consumer key as the username
// and the consumer secret as the password". To comply we are resorting to overriding
// node-oauth's implmentation of getOAuthAccessToken().

Thats great sebilasse, is there any typescript implementation?

C0DE-IN avatar Dec 07 '21 07:12 C0DE-IN