OAuth2 with Google Content for Shopping API

Is anyone familiar with Google’s Content for Shopping API?

I’m trying to authorize using OAuth 2.0… I get all the way to the getting the token code, but then I get the following error. I can’t believe there’s an issue with the library.

Has anyone experienced this error before?

Fatal error: Uncaught exception ‘GSC_TokenError’ with message ‘invalid_request’ in /home/sites//public_html/includes/GShoppingContent.php:624 Stack trace: #0 /home/sites//public_html/includes/GShoppingContent.php(663): GSC_OAuth2Token::raiseFromJson(Object(_GSC_Response)) #1 /home/sites//public_html/oauth2callback.php(12): GSC_OAuth2Token->getAccessToken(‘4/nTrHBnpUy08da…’) #2 {main} thrown in /home/sites//public_html/includes/GShoppingContent.php on line 624

Here’s the script, which I’ve basically just copy and pasted from Google’s documentation:


require_once('includes/GShoppingContent.php');

const ACCOUNT_ID = '9170578';
$client = new GSC_Client(ACCOUNT_ID);

const CLIENT_ID = 'blahblahblah.apps.googleusercontent.com';
const CLIENT_SECRET = '*topsecret*';

$authToken = new GSC_OAuth2Token(CLIENT_ID, CLIENT_SECRET, USER_AGENT);

$authToken->getAccessToken($_GET['code']);

$client->setToken($authToken);

The url obviously contains a long code which is used to get the access token.

Many thanks,
Mike