Google Javascript API (gapi) - problems with .load

Viewed 5040

I am trying to use the Google plus API (via googie-api-javascript) implementation like so (omitting full code):

var clientId = '7454475891XxxxxxXom4c6n.apps.googleusercontent.com'; //fake client
var apiKey = '-uTH_p6NokbrXXXXXXXXXXXXX'; //Fake Key
var scopes = 'https://www.googleapis.com/auth/plus.me';

function handleClientLoad() {
   gapi.client.setApiKey(apiKey);
   window.setTimeout(checkAuth,1);
}

function checkAuth() {
   gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: true}, handleAuthResult);
}


function handleAuthResult(authResult) {        
  if (authResult && !authResult.error) {          
    makeApiCall();
  } else {
    //handle user-approval
  }
}

  // Load the API and make an API call.  Display the results on the screen.
function makeApiCall() {
    gapi.client.load('plus', 'v1', function() {
      var o = gapi.client.plus;
      alert(o);
    });
}

The code works well upto the point of gapi.client.load (including the user allowing access) - this callback gets called but alert(o) will return undefined.

Upon inspecting the HTTP request I see the .load issues a request to:

https://content.googleapis.com/discovery/v1/apis/plus/v1/rpc?fields=methods%2F*%2Fid&pp=0&key=-uTH_p6NokbrXXXXXXXX

This returns HTTP 400 with the following message:

{"error":{"errors":[{"domain":"usageLimits","reason":"keyInvalid","message":"Bad Request"}],"code":400,"message":"Bad Request"}}

My question is - what do I need to change to make this work? Is there some secret setting I need to enable ? Google+ is enabled in the google-developer-console under the APIs list.

Thanks for the help, Alon

3 Answers
Related