node-oauth
node-oauth copied to clipboard
Oauth2 with Reddit
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.
It doesn't break Facebook either.
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?
Hit this same problem myself.
My workaround is to pass custom headers as the last parameter to the OAuth2 constructor:
new OAuth2(..,..,. ... { 'Authorization': 'Basic ZlZfTkdsY3NNNV' });
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().
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?