Connecting to Adobe Share using Python
Adobe recently launched the Share Beta, a state of the art flash based file sharing and archiving solution. All of these services are headed in only one direction, the web. Also, there is an increasing desire to make connecting to these services easier. Adobe Share uses the RESTful paradigm to allow users to connect to the back end and communicate with the server, for automating tasks that would usually require user interaction.The Share forums currently provide links to API's for connecting to the service in Java and Action Script 3. I am not comfortable with either, and I wanted to use Python for this purpose, because it fits in well with my wider objective, and hence I can script everything in a single language. After hours of frantic searching, I wasn't able to find a decent tutorial on the RESTful methods in Python, leave alone Adobe Share specific help.
So after much hard work, I was able to get the responce I wanted, and after several ugly monsters like
'BadSig'
'BadAuthQuery'
and several others, I finally saw the light, and the server said:
'<response status="ok"><authtoken>2a5b93f2321a78172062219ab8ce3f25</authtoken></response>'</blockquote>
aah.. isn't that pretty.... You will surely understand if you have been trying as hard as I had to. So this is the end of one (no not all, its not panacea, just a lil blog, whatdayaexpect!) of your woes. This post will describe the very basics of getting a AuthToken using the Adobe Share API from Python.
So lets get started,
First things first, what all do you need over and above the standard Python installation? Only httplib2. (I use Python 2.5.1, and that seems to have everything else for this task anyway).
Import all you need, and create the data string and signature as described in the Share API documentation:
>>> import time, md5, httplib2
>>> shared = "085960468662212c21417dce2e1XXXXX"
>>> datastring = "POST /webservices/api/v1/auth/ apikey=fdc464509d733be99c30c6ccfacXXXXX calltime=" + str(int(time.time()))
>>> datastring
'POST /webservices/api/v1/auth/ apikey=fdc464509d733be99c30c6ccfacXXXXX calltime=1192904962'
>>> sig = (md5.new(datastring+shared).hexdigest())
>>> url = "https://api.share.adobe.com/webservices/api/v1/auth/?apikey=fdc464509d733be99c30c6ccfacXXXXX&calltime=1192904962&sig=" + sig
>>> bodydata = '<request><username>vkapoor@adobe.com<password>XXXXXXX</password>'
>>> http = httplib2.Http()
>>> response, content = http.request(url , method='POST', body=bodydata)
>>> response
{'date': 'Sat, 20 Oct 2007 18:33:18 GMT', 'status': '200', 'content-length': '88', 'content-type': 'application/xml;charset=ISO-8859-1', 'server': 'Apache-Coyote/1.1'}
>>> content
'<response status="ok"><authtoken>156e799bf4cac31eee170c2116cf5646</authtoken></response>'
So, there. Thats the first step for establishing a connection with the Adobe Share server, using Python and the RESTful approach. I will soon update on setting up a session, and uploading a PDF using Python. Stay tuned..
Labels: Adobe, Python, RESTful, Share, Web
About this entry
You’re currently reading “
- Published:
- 11:35 PM
- by Vivek



1 Comments (Post a Comment)