reloadAuthResponse for gapi.auth2 (#16061)

This commit is contained in:
Mykhailo96
2017-04-26 21:34:36 +03:00
committed by Sheetal Nandi
parent 0cc7d8bb62
commit 53ada7c0c2
2 changed files with 19 additions and 6 deletions

View File

@@ -41,6 +41,14 @@ function test_getAuthResponse() {
var authResponseWithAuth = user.getAuthResponse(true);
}
function test_reloadAuthResponse() {
gapi.auth2.getAuthInstance().currentUser.get().reloadAuthResponse()
.then(response => {
let token = response.access_token;
let expires_in = response.expires_in
})
}
function test_render() {
var success = (googleUser: gapi.auth2.GoogleUser): void => {
console.log(googleUser);
@@ -103,10 +111,10 @@ function handleClientLoad() {
}
function initClient() {
gapi.client.init({
apiKey: apiKey,
discoveryDocs: discoveryDocs,
clientId: clientId,
scope: scopes
apiKey: apiKey,
discoveryDocs: discoveryDocs,
clientId: clientId,
scope: scopes
}).then(function () {
// Listen for sign-in state changes.
gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
@@ -136,10 +144,10 @@ function handleSignoutClick(event: MouseEvent) {
function makeApiCall() {
gapi.client.people.people.get({
resourceName: 'people/me'
}).then(function(resp) {
}).then(function (resp) {
var p = document.createElement('p');
var name = resp.result.names[0].givenName;
p.appendChild(document.createTextNode('Hello, '+name+'!'));
p.appendChild(document.createTextNode('Hello, ' + name + '!'));
document.getElementById('content').appendChild(p);
});
}