Google Authorizing
Authorizing and Making Authorized Requests
HTML
<button onclick="auth();">Authorize</button>
JavaScript
function auth() {
var config = {
'client_id': 'YOUR CLIENT ID',
'scope': 'https://www.googleapis.com/auth/urlshortener'
};
gapi.auth.authorize(config, function () {
console.log('login complete');
console.log(gapi.auth.getToken());
});
}