«

»

Oct
03

Google and OAuth problems

Okay, I’ve lost like three days on this, so I really have to write it down.

It happened I found myself trying to connect to Google using the Google Data API for retrieving the user contacts (in my case I was using Python and Django, but it doesn’t really matter). I was – after a while – able to get an access token, but I was unable to actually download data: Google always returned an error page saying:

401. That’s an error.
There was an error in your request. That’s all we know.

Thanks, Google.

Well, playing around with the OAuth Playground (very bugged, but useful) I realized the problem was with my access token, so I debugged a bit. It just happens that Google returns you an escaped access token, in my case:

1%2FAhSlGsMB_2VHwzMI3Y9X0op5VWsciV-NZqM3PoZESG0

While the actual (unescaped) token was

1/AhSlGsMB_2VHwzMI3Y9X0op5VWsciV-NZqM3PoZESG0

After running a simple

urllib.unquote

on it, I was finally able to download data.

Leave a Reply

Your email address will not be published.


× nine = 81