Sory, 148.
Here is the [link](https://github.com/GluuFederation/oxAuth/blob/master/Server/src/main/webapp/auth/gplus/gpluslogin.xhtml#L148) on github.
Basically move the javascript to the beginning:
<script type="text/javascript">
//<![CDATA[
var helper = (function() {
var authResult = undefined;
return {
/**
* Hides the sign-in button and connects the server-side app after
* the user successfully signs in.
*
* @param {Object} authResult An Object which contains the access token and
* other authentication information.
*/
onSignInCallback: function(authResult) {
// for (var field in authResult) {
// console.log('Auth result field: ' + field + ': ' + authResult[field]);
// }
if (authResult['access_token']) {
// The user is signed in
this.authResult = authResult;
$('#gConnect').hide();
helper.connectServer();
} else if (authResult['error']) {
// There was an error, which means the user is not signed in.
// As an example, you can troubleshoot by writing to the console:
console.log('There was an error: ' + authResult['error']);
$('#gConnect').show();
}
},
/**
* Submit login form with tokens to server
* For more information, see:
* https://developers.google.com/+/web/signin/server-side-flow
*/
connectServer: function() {
$("input[name='gplus_auth_code']").val(this.authResult["code"]);
$(":input:submit[id='loginForm:loginButton']").click();
},
};
})();
/**
* Calls the helper method that handles the authentication flow.
*
* @param {Object} authResult An Object which contains the access token and
* other authentication information.
*/
function onSignInCallback(authResult) {
helper.onSignInCallback(authResult);
}
//]]>
</script>