Question

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?

Was it helpful?

Solution

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}"} 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top