getGoogleAccessToken
Opens a new window to get user access from Google to a specific scope.
Description
vcc.getGoogleAccessToken(json: object, scope: string, callback: Function): void
Parameters
json
Client ID for native application.
scope
Name of the requested scope.
callback
This function will be retrieved with the access_token.
Return values
none
Example
Get information from Google about the agent’s account.
var json = {"installed":{...}};
vcc.getGoogleAccessToken(json, 'email profile', function(accessToken) {
var request = vcc.httpRequest();
request.open('GET', 'https://www.googleapis.com/plus/v1/people/me');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Authorization', 'Bearer '+accessToken);
request.onload = function(e) {
var user = JSON.parse(request.responseText);
dump(user);
vcc.setFieldValue('op_name', user.displayName);
vcc.setFieldValue('op_email', user.email[0].value);
};
request.send();
});
Comments
Can’t find what you need? Use the comment section below to connect with others, get answers from our experts, or share your ideas with us.
There are no comments yet.