Django AllAuth with Twitter Error: "No access to private resources at api.twitter.com"
I'm trying to setup the Django AllAuth Twitter login. When the user authenticates with Twitter and is redirected to my website, Django AllAuth raises the Error "No access to private resources at api.twitter.com" and I'm pretty lost here. I have the following settings in my settings.py:
SOCIALACCOUNT_PROVIDERS = {
"twitter": {
# From https://developer.twitter.com
"APP": {
"client_id": os.environ["TWITTER_API_KEY"],
"secret": os.environ["TWITTER_API_SECRET"],
}
},
}
My app has the following privilege rights in the developer portal:
- OAuth1 Endpoints
- OAuth2 Endpoints
- User Email
- Read Tweets and Profiles
Any ideas why this could be happening? Thanks in advance!
The reason this is happening is that your developer account doesn't have access to the v1.1 API. To do so you need to apply for the 'Elevated' API access level as described here: https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api
I was getting the exact same error as you, and then tried it again on an older dev account I have that is grandfathered in to Elevated, and everything started working for me. (Any dev account created before Nov 2021 automatically has Elevated access.)
i am still having a different problem after going through the process of creating the headers and hashing.
i used this library that streamlines the OAuth1 and i believe the OAuth2 process, with the consumer key and secret and no need of nonce or timestamps.
they also go through some twitter API examples that helped me for another API.
posting in case this helps someone else.