-
-
Notifications
You must be signed in to change notification settings - Fork 919
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
add OAuth example to readme (#219) #221
Conversation
method: 'GET' | ||
}; | ||
|
||
got(request_data.url, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to specify the json: true
option
@sindresorhus I'll close this and open a new PR (squashed) ok? |
@thisconnect, @sindresorhus can squash on merge, I don't think you have to create a new PR. |
nice to know, thanks :) |
BTW: option.query can NOT be used with OAuth as the query has to be part of the requestData.url in oauth.authorize |
alternative: const got = require('got');
const OAuth = require('oauth-1.0a');
const oauth = OAuth({
consumer: {
public: process.env.CONSUMER_KEY,
secret: process.env.CONSUMER_SECRET
},
signature_method: 'HMAC-SHA1'
});
const token = {
public: process.env.ACCESS_TOKEN,
secret: process.env.ACCESS_TOKEN_SECRET
};
const url = 'https://api.twitter.com/1.1/statuses/home_timeline.json';
got(url, {
headers: oauth.toHeader(oauth.authorize({ url: url, method: 'GET' }, token)),
json: true
}); |
👍
|
const url = 'https://api.twitter.com/1.1/statuses/home_timeline.json'; | ||
|
||
got(url, { | ||
headers: oauth.toHeader(oauth.authorize({ url, method: 'GET' }, token)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove spaces inside the object {url, method: 'GET'}
Looks great! Thanks @thisconnect :) |
Thank you too!! |
No description provided.