How to request Twitter 1.1 API using oauth_token you provided?

The Twitter 1.1 API requires an OAuth token. My understanding of OAuth is that you need to request an authentication token using the cunsumer key, sectarian, nounce, etc. After you receive the OAuth token, you should have access to the API using ONLY this OAuth token.

Following the steps on Twitter, I get examples of how to authenticate / sign the token, but I can not find an example of how to access the API (for example, search) using oauth_token.

When executing the following GET request:

https://api.twitter.com/1.1/search/tweets.json?q=freebandname 

I get (of course) the "Bad Authentication" response.

I expect this to work when adding a dedicated OAuth token, but I have no idea how to do this.

Performance:

 https://api.twitter.com/1.1/search/tweets.json?q=freebandname&oauth_token=aaaxx-xxx-xxx-xxxx 

It also returns a "Bad Authentication" response.

I also tried to pass only the oauth_token header in the header, but this also returns a "Bad Authentication" response.

So basically my question is:

How can I request the Twitter 1.1 API only with the OAuth token you provided?

+7
source share
1 answer

Well, finally, I found the answer, and that was pretty clear in the Twitter 1.1 API documentation. The documentation says that you should pass the token in the request header named "Bearer".

Everything is clear here: https://dev.twitter.com/docs/auth/application-only-auth

To implement, scroll down to the section โ€œIssue requests only for applicationsโ€.

+3
source

All Articles