Search code examples
pythontwitter-oauth

Is is possible to use email and password in Twitter API instead of API key and secret?


The twitter API endpoint (twitter.com/oauth2/token) requires API-Key and Secret in Basic Authorization header.

Code

headers = {
    'Authorization': 'Basic '+ str(base64.b64encode('API-KEY:API-SECRET'.encode('utf-8')).decode('utf-8')),
}

What I would like to do:

headers = {
    'Authorization': 'Basic '+ str(base64.b64encode('MY-EMAIL:MY-PASSWORD'.encode('utf-8')).decode('utf-8')),
}

Is it possible?


Solution

  • No, this is not possible. Email and password are not suitably secure to be used in Twitter application authentication with the API (and should never be typed into third party apps or services).