Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAuth2 for twitter don't work #143

Open
popomore opened this issue May 26, 2013 · 7 comments · May be fixed by #316
Open

OAuth2 for twitter don't work #143

popomore opened this issue May 26, 2013 · 7 comments · May be fixed by #316

Comments

@popomore
Copy link

var twitterConsumerKey = '';
var twitterConsumerSecret = '';

var OAuth2 = require('oauth').OAuth2;
var oauth2 = new OAuth2(
  twitterConsumerKey,
  twitterConsumerSecret,
  'https://api.twitter.com/',
  null,
  'oauth2/token',
  null
);
oauth2.getOAuthAccessToken(
  '',
  {'grant_type':'client_credentials'},
  function (e, access_token, refresh_token, results){
     console.log('bearer: ',access_token);
  }
);

access_token return undefined

@qur2
Copy link

qur2 commented Jun 12, 2013

Well, if you look at the first param, there is an error:

{ '0':
   { statusCode: 403,
     data: '{"errors":[{"code":99,"label":"authenticity_token_error","message":"Unable to verify your credentials"}]}' } }
bearer:  undefined

I'm trying to do the same, but it seems that OAuth2 puts the params such has grant_type in the request body rather than the headers.

@ciaranj
Copy link
Owner

ciaranj commented Jun 12, 2013

And you're sure this is nothing to do with: https://dev.twitter.com/blog/api-v1-is-retired ?

@qur2
Copy link

qur2 commented Jun 12, 2013

Oh yes, it has, definitely. Personally I was still on wild query to get my timeline, no auth at all. So now I have to implement that and I thought my use case needs this app-only auth. This issue was recent and I thought I'd expose my findings.
I would make a pull request for that, but the problem is that it's twitter specific, isn't it?
Right now I'm inspecting possible solutions with passportjs and passport-twitter.

@ciaranj
Copy link
Owner

ciaranj commented Jun 12, 2013

@qur2 I'm not too sure, but it certainly looks as though its an issue with your specific configuration rather than the actual library itself :)

@qur2
Copy link

qur2 commented Jun 12, 2013

I'm not even sure it's the library to use for those twitter application-only requests. I'm trying to achieve the same as the bug reporter and saw that there was an error. So his problem is not the undefined value but rather the fact that authentication fails.

Right now I'm digging on passportjs side as I already rely on it. If it's just for me, you can close the bug, I won't miss it 🔨

@sebinsua
Copy link

sebinsua commented Sep 8, 2013

Yeah, this doesn't work. I was trying to use Oauth2.get() in the way shown on this site: http://webapplog.com/node-js-oauth1-0-and-oauth2-0-twitter-api-v1-1-examples/

The solution was just to make a normal HTTP request, like so: https://gist.github.com/Dakuan/5899971

Otherwise I was getting this: { statusCode: 400, data: '{"errors":[{"message":"Bad Authentication data","code":215}]}' }

@sebilasse
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants