Skip to content

Commit

Permalink
Hide auth/signout buttons initially
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinthecheung committed Jun 8, 2016
1 parent 8262319 commit 670e317
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions samples/authSample.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<p>Say hello using the People API.</p>

<!--Add buttons to initiate auth sequence and sign out-->
<button id="authorize-button">Authorize</button>
<button id="signout-button" display="none">Sign Out</button>
<button id="authorize-button" style="display: none;">Authorize</button>
<button id="signout-button" style="display: none;">Sign Out</button>

<div id="content"></div>

Expand Down Expand Up @@ -60,20 +60,25 @@
}

function initAuth() {
auth2 = gapi.auth2.init({
gapi.client.setApiKey(apiKey);
gapi.auth2.init({
client_id: clientId,
scope: scopes
});
gapi.client.setApiKey(apiKey);
}).then(function () {
auth2 = gapi.auth2.getAuthInstance();

// Listen for sign-in state changes.
auth2.isSignedIn.listen(signinChanged);
// Listen for sign-in state changes.
auth2.isSignedIn.listen(updateSigninStatus);

authorizeButton.onclick = handleAuthClick;
signoutButton.onclick = handleSignoutClick;
// Handle the initial sign-in state.
updateSigninStatus(auth2.isSignedIn.get());

authorizeButton.onclick = handleAuthClick;
signoutButton.onclick = handleSignoutClick;
});
}

function signinChanged(isSignedIn) {
function updateSigninStatus(isSignedIn) {
if (isSignedIn) {
authorizeButton.style.display = 'none';
signoutButton.style.display = 'block';
Expand Down

0 comments on commit 670e317

Please sign in to comment.