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:
- Login the user using javascript (window popup)
- Send the
access_token
to server - Use the
access_token
server-side, i.e. retrieve account data (Google Analytics for example).