I need to upload images to Photobucket using the API wrapper for Python. I can get the request_token and request_token_secret but not the final access_token and access_token_secret. Instead, I get the following error message:
pbapi.error.PbApiError: (): Token and Token Secret not in response
The response I get is the following:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<status>Exception</status>
<message>Authentication failed no token</message>
<code>7</code>
<format>xml</format>
<method>POST</method>
<timestamp>1355787388</timestamp>
</response>
<!-- phx1api05 @ Mon, 17 Dec 2012 16:36:28 -0700 -->
Here is my code:
api = pbapi.PbApi(API_KEY, API_SECRET)
api.pb_request.connection.cache = None
# Getting request token
api.reset().login().request().post().load_token_from_response()
# Requesting user permission (you have to login with your account)
webbrowser.open_new_tab(api.login_url)
raw_input("Press Enter when you finished access permission. ")
#Getting oAuth token
#api.reset().login().access().post().load_token_from_response()
print api.reset().login().access().post().response_string
Please help.
Photobucket is an extremely difficult provider because of the way they redirect endpoints. However I'm a little surprised their own wrapper doesn't work. I would recommend rauth but it won't work out of the box: you'd have to subclass the signature object which manually overloads the URL to sign, i.e. setting it to
'api.photobucket.com'and then pass your custom signature object into the session constructor. It's doable but a tad bit messy. I have this working for a project at work, but I don't have an example I can provide for you right now.