4

When using Googles JavaScript API to auth a user, I would like to send the access_token to the server, and continue grabbing information using the access_token retrived by the JavaScript API.

gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: false}, handler);

...

function handler(result) {
    console.log("Access token: " + result.access_token);
}

The login works just fine, the handler function is called, and I'm able to access the access_token. Once it has been sent to the server, it's not able to use the access_token. The server is using https://code.google.com/p/google-api-php-client/ to communicate with Google. The API returns an error saying that the access_token has expired, but it was generated just seconds ago.

Both client/server side uses the same settings (clientId, apiKey and scope).

This is what I'm trying to do:

  1. Login the user using javascript (window popup)
  2. Send the access_token to server
  3. Use the access_token server-side, i.e. retrieve account data (Google Analytics for example).
Robin
  • 187
  • 1
  • 10

0 Answers0