Skip to content

How to upload profile image with oauth2 and python  #165

@rajasimon

Description

@rajasimon

I have my working code that can update my status for me but now i am testing to update my profile picture . And i have doubt I can able to update my profile image right ? Below is my code ..

image_post = "https://api.twitter.com/1.1/account/update_profile_image.json?image={}".format(base64encode)
resp, content = client.request(image_post, "POST")
pprint.pprint(content)

Output :

'{"errors":[{"message":"Could not authenticate you","code":32}]}'

I looked into Twitter response-codes, they mention two follows ..

  1. Could not authenticate you _Your call could not be completed as dialed._
  2. Could not authenticate you _Corresponds with a HTTP 401 - it means that your oauth_timestamp is either ahead or behind our acceptable range_

Please somebody tell me how to resolve this ?

Note: (Django 1.7, Python 2.7, Python-oauth2, )

My question related to this but i damn sure my form have multipart ...

After more digging before posting this i found in twitter documentation ...

Timestamp
The oauth_timestamp parameter indicates when the request was created. This value should be the number of seconds since the Unix epoch at the point the request is generated, and should be easily generated in most programming languages. Twitter will reject requests which were created too far in the past, so it is important to keep the clock of the computer generating requests in sync with NTP.

So how to sync ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions