Skip to content
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

Error: Unauthorized when using tweets/search/all #74

Open
dolanmiu opened this issue Apr 16, 2021 · 4 comments
Open

Error: Unauthorized when using tweets/search/all #74

dolanmiu opened this issue Apr 16, 2021 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@dolanmiu
Copy link

dolanmiu commented Apr 16, 2021

It works 100% perfectly when tweets/search/recent, but as soon as I switch to tweets/search/all, it falls apart

Works:

const { data } = await client.get("tweets/search/recent", { query: "test" });

Does not work:

const { data } = await client.get("tweets/search/all", {
    query: "test",
    start_time: yesterday.toUTCString(),
    end_time: new Date().toUTCString()
});

If it omit start_time and end_time, it gives:

Error: Unsupported Authentication: Authentication with OAuth 1.0a User Context is forbidden. Please, make the request with OAuth 2.0 Bearer Token authentication.

@ErikKalkoken
Copy link

I had a similar issue when trying the streams API for 'tweets/search/stream'. Switching to a bearer token solved it for me.

@dolanmiu
Copy link
Author

@ErikKalkoken How do I switch to Bearer token?

Got a code sample?

@ErikKalkoken
Copy link

ErikKalkoken commented Apr 19, 2021

@dolanmiu

I used the example from the README:

const client = new Twitter({
  bearer_token: '',
});

@HunterLarco
Copy link
Owner

HunterLarco commented Apr 20, 2021

Note that the tweets/search/all is only available to users who have been approved for the Academic Research product track. See twitter documentation for details.

I suspect you're seeing authentication errors because tweets/search/recent is available to every API user unlike the all corpus.

Unfortunately auth failures such as this one tend to be very cryptic.

@HunterLarco HunterLarco self-assigned this Apr 20, 2021
@HunterLarco HunterLarco added the question Further information is requested label Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants