The Twitter 1.1 API requires an OAuth token. My understanding of OAuth is that you need to request an authentication token using a cunsumer key, sectret, nounce, etc. Once you have received an OAuth token you should be able to access the API using ONLY that OAuth token.
When following the steps on Twitter I get examples on how to authenticate/sign the token, but I can't seem to find an example on how to access the (e.g. search) API with my oauth_token.
When executing the following GET request:
https://api.twitter.com/1.1/search/tweets.json?q=freebandname
I get (of course) a 'Bad Authentication data' response.
I would expect it would work when adding the granted OAuth token, but I have no idea how to do that.
Executing:
https://api.twitter.com/1.1/search/tweets.json?q=freebandname&oauth_token=aaaxx-xxx-xxx-xxxx
Also it returns a 'Bad Authentication data' response.
I also tried to pass only the oauth_token in the header, but this also returns a 'Bad Authentication data' response.
So basically my question is:
How do I request the Twitter 1.1 API with only your granted OAuth token?
Step 1: getRequestToken () – sends the oauth_callback with the authentication header. It requests request_token and the secrete key from the Twitter API. Step 2: getOAuthVerifier () – redirects the user to the Twitter authentication page.
An authentication step ensures access security on each API request. Twitter uses various authentication methods. Those are, OAuth 1.0a, OAuth 2.0 Bearer token, Basic authentication. I used OAuth 1.0a authentication to validate login with Twitter API requests. During the login flow, Twitter prompts to enter user credentials to login.
To make any request to the Twitter API (in python or anywhere else) you require your API Key and Access Token. For this, you need to apply for a developer account with Twitter and have your account approved. Once approved, you can create a project and associate it with a sample App.
by Vincy. Last modified on December 27th, 2020. Almost all Internet giants (in good sense) like Google, Facebook, Twitter and LinkedIn support OAuth login. They provide API with detailed documentation to help developers integrate OAuth authentication. There are many client libraries available to implement Twitter OAuth login.
Well, I finally found the answer and it was pretty clear in the Twitter API 1.1 documentation. The documentation says you have to pass the token in the request header with the name 'Bearer'.
Everything is pretty clear explained here: https://dev.twitter.com/docs/auth/application-only-auth
For the implementation, scroll down to the 'Issuing application-only requests' section.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With