[Tutor] getting binary file from website with custom header
Steven D'Aprano
steve at pearwood.info
Sat Jan 29 07:38:03 CET 2011
Alex Hall wrote:
> Sorry. http://api.bookshare.org.
Hmmm, I get:
403 Developer Inactive
so that's no help to me. However, I did find this:
http://developer.bookshare.org/docs/Home/
[quote]
For user authenticated services, the user's username will be passed in
via the for parameter in the endpoint path. The password should be
derived as (Java syntax): md5sum(userPassword), where userPassword is
the password of the user on whose behalf the service is being requested.
[end quote]
Unfortunately, that might be Java syntax (and also C syntax, Python
syntax, Fortran syntax, and about a million other languages...) but
there's no clue as to what the result should look like. Do they want an
numeric string? In decimal or some other base? A string?
>> It may matter. urllib has some problems with https.
> Wonderful... Time to find another package?
Not necessarily. Don't jump to conclusions. "Some problems" doesn't
necessarily mean that you're seeing them.
>> What makes you think you should use the *hex* digest of the password,
>> rather than some other format?
> Honestly, it seemed the logical choice, and the api docs to not say
> anything except to md5Sum() the password. I have tried it with and
> without the hexdigest() and nothing changed. I will look to see what
> else hashlib provides.
Try urllib.quote(hashlib.md5(password).digest()) and see if that helps.
But having said that...
> The url should be right. I am now at an error 500 instead of 403,
> which is rather strange. I know 500=internal server error, but as far
> as I know the api is not down.
Sounds to me that whatever their server is using to authenticate is broken.
--
Steven
More information about the Tutor
mailing list