Problems authenticating..

bvelasquez's Avatar

bvelasquez

02 Jun, 2009 05:29 PM via web

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

  1. Support Staff 2 Posted by Adam Kalsey on 02 Jun, 2009 06:54 PM

    Adam Kalsey's Avatar

    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

  2. 3 Posted by bvelasquez on 02 Jun, 2009 07:03 PM

    bvelasquez's Avatar

    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??

  3. 4 Posted by bvelasquez on 02 Jun, 2009 07:06 PM

    bvelasquez's Avatar

    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.

  4. Support Staff 5 Posted by Adam Kalsey on 02 Jun, 2009 07:10 PM

    Adam Kalsey's Avatar

    Perfect. Mind if we use that code as an example?

  5. 6 Posted by bvelasquez on 02 Jun, 2009 07:13 PM

    bvelasquez's Avatar

    Here is the the code cleaned up. Absolutely use it! :)

    http://pastie.org/498016

    With comments.

    Barry

  6. 7 Posted by bvelasquez on 03 Jun, 2009 10:58 PM

    bvelasquez's Avatar

    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

  7. Support Staff 8 Posted by Adam Kalsey on 04 Jun, 2009 01:41 AM

    Adam Kalsey's Avatar

    Thanks, looks like the help system is trying to turn that email
    address into a link automatically. I'll look into it.

Comments are currently closed for this discussion. You can start a new one.