views:

12

answers:

0

So I've been trying to use OAuth to connect to Google APIs. I've succeeded so far in getting the Token Secret. But when I try to make a request to one of the data APIs like https://www.google.com/analytics/feeds/data and sign the request - i'm getting some errors.

I used the OAuth Playground (http://googlecodesamples.com/oauth_playground/) which is very useful to debug issues. I made sure that I use the same Secret keys and Base String to setup the signature in my PHP code. But it looks different from the one on OAuth Playground.

Here's the code:

$base_string = "GET%26https%253A%252F%252Fwww.google.com%252Fanalytics%252Ffeeds%252Fdata...

$key = $consumer_secret . '&' . $token_secret;

$signature = base64_encode(hash_hmac('sha1', $base_string, $key, true));

The Signature produced looks different from the one on OAuth Playground even though everything else is the same. Please help!