Problems authenticating..
Hello,
I have been trying to use the getuser method of the API. I get a 200 return code, so the call worked, but the body of the response is:
<rsp stat="fail">
<err msg="Your username/password/botkey was not valid!"/>
</rsp>
I'm using the botkey.. checked it many times. I'm using python
to make the call from Google App Engine.
Here is the Python GAE Handler I am using:
http://pastie.org/private/ncv3d9vzzek3vmelamrrqa [UPDATE: Use pastie link at bottom for final example.]
I'm using Basic Auth. and setting the header appropriately (I think). I base 64 the username and password combo and set it in the Authentication header. I've also tried not encoding based on a forum response in the google group.
Any ideas?
Barry
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Adam Kalsey on 02 Jun, 2009 06:54 PM
I marked your post as private since you have your botkey and email
address in the pastebin. If you want to add a different pastebin
without your private details, we can make this public again.
I'm not a python developer, but it looks like you might not be sending
the authentication header properly. You need to add an http header to
your request that says:
Authorization: Basic {your-base64-auth-token}
Your pastie looks like you're sending "AUTH :
{your-base64-auth-token}" as part of your form post.
There's some detailed instructions on how to do basic auth with Python
at http://www.voidspace.org.uk/python/articles/authentication.shtml
3 Posted by bvelasquez on 02 Jun, 2009 07:03 PM
I changed the Pastie to take out private information. I'm trying the example. There is a [:-1] at the end of the authentication string. Maybe you need to crop off some extra character??
4 Posted by bvelasquez on 02 Jun, 2009 07:06 PM
The extra [:-1] is all that was needed. Go figure. I suspect base64'n the string ads an extra character. I'll need to understand base64 better to know why this is the case. In any case, my pastie is a good example of accessing the service via Python and GAE. Thanks.
Support Staff 5 Posted by Adam Kalsey on 02 Jun, 2009 07:10 PM
Perfect. Mind if we use that code as an example?
6 Posted by bvelasquez on 02 Jun, 2009 07:13 PM
Here is the the code cleaned up. Absolutely use it! :)
http://pastie.org/498016
With comments.
Barry
7 Posted by bvelasquez on 03 Jun, 2009 10:58 PM
Hello,
Noticed the example posted has incorrect Authentication string content.
base64string = base64.encodestring('%s:%s' % ('<a href="mailto:youname@email.com">youname@email.com</a>', 'password'))[:-1]There should be no a tag and href in there, just your email address. I think maybe the cut and paste didn't work and it copied the underlying HTML from the original post.
Barry
Support Staff 8 Posted by Adam Kalsey on 04 Jun, 2009 01:41 AM
Thanks, looks like the help system is trying to turn that email
address into a link automatically. I'll look into it.