I'm having trouble with authorization, how can I troubleshoot?

faq

#1

Once you have been approved for a developer account, review the following to check your access for the premium APIs.

Set up your dev environments:
Check your app credentials on the ‘App Name’ listed on your dev environment here. Clicking on the App should take you to your app page URL with the format below, the App ID is 987654321 in this example:

https://apps.twitter.com/app/987654321/show

Review your permission model:
If planning to use the Account Activity API, ‘Read, Write, Direct Messages’ must be selected.

App-only Authorization:
Find your full ‘Consumer Key’ and ‘Consumer Secret’ under the “Keys and Access Tokens” tab here: https://apps.twitter.com/app/987654321/keys

Create a bearer token to use with the Search 30day and Search FullArchive premium APIs.
Review the documentation on how to create a bearer token from your Consumer Key and Consumer Key Secret: https://developer.twitter.com/en/docs/basics/authentication/overview/application-only
Take these to create your bearer token, for example like below:

curl -X POST "https://api.twitter.com/oauth2/token" -u "<ConsumerKey>:<ConsumerSecret>" -d "grant_type=client_credentials"

This should return your bearer token:

{"token_type":"bearer","access_token":"xxxXXXXXXxxxxxxxxXXXXXXXXxxxxxXXXX%0xxXXXxxxXX%0XXXxXXxxI%0xxxXXXXverylongIDXXxxxX"}

Then you can use the bearer token in either a GET or POST call, remember to put your ‘Dev environment label’ into the endpoint:

curl "https://api.twitter.com/1.1/tweets/search/30day/<DevEnvironmentLabel>.json?maxResults=100&query=blue" -H "Authorization: Bearer xxxXXXXXXxxxxxxxxXXXXXXXXxxxxxXXXX%0xxXXXxxxXX%0XXXxXXxxI%0xxxXXXXverylongIDXXxxxX"

curl -X POST "https://api.twitter.com/1.1/tweets/search/30day/<DevEnvironmentLabel>.json" -H "Authorization: Bearer xxxXXXXXXxxxxxxxxXXXXXXXXxxxxxXXXX%0xxXXXxxxXX%0XXXxXXxxI%0xxxXXXXverylongIDXXxxxX" -d '{"maxResults":100,"query":"blue"}'

App-User Authorization:
Various requests in the Account Activity API, require authorization from users in order to create subscriptions. Please review how to obtain access_tokens through 3-legged-oauth here: https://developer.twitter.com/en/docs/basics/authentication/overview/3-legged-oauth


Twitter Webhook Registration: Could not authenticate you
Frequently Asked Questions
How to test proper account setup and endpoint access?
#2