Reputation: 49
I'm trying to connect to Twitter's REST API using application-only authentication. I get the bearer token, but the GET request doesn't work.
token = TOKEN
response = RestClient.get "https://api.twitter.com/1.1/followers/ids.json?screen_name=twitter", {headers: {'Authorization' => "Bearer #{token}"}}
Am I doing something incorrect with rest-client?
Upvotes: 0
Views: 455
Reputation: 5019
You don't need the "headers"-key. Since the hash after the URL is for headers your request will contain a header with the name "headers" rather than "Authoriziation".
It should work by just removing "headers":
RestClient.get "https://api.twitter.com/1.1/followers/ids.json?screen_name=twitter", {'Authorization' => "Bearer #{token}"}
Upvotes: 1