var clientId = 'my-client-id';
var apiKey = 'my-api-key';
var scopes = 'profile https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/youtube';
var signinButton = document.getElementById('signin');
var signoutButton = document.getElementById('signout');
function initAuth() {
gapi.client.setApiKey(apiKey);
gapi.auth2.init({
client_id: clientId,
scope: scopes
}).then(function() {
// Listen for sign-in state changes.
gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
// Handle the initial sign-in state.
updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
signinButton.addEventListener("click", handleSigninClick);
signoutButton.addEventListener("click", handleSignoutClick);
});
}
function updateSigninStatus(isSignedIn) {
if (isSignedIn) {
signinButton.style.display = 'none';
signoutButton.style.display = 'block';
} else {
signinButton.style.display = 'block';
signoutButton.style.display = 'none';
}
}
function handleSigninClick(event) {
gapi.auth2.getAuthInstance().signIn();
}
function handleSignoutClick(event) {
gapi.auth2.getAuthInstance().signOut();
}
// Load the API client and auth library
gapi.load('client:auth2', initAuth);
TL;DR:
Does anyone know if the Google Javascript Client API library supports authenticating as a Google+ Page, and if so, how I should be handling what is being returned?
Thanks!