logout doesnt appear with google login
my google+ login is working fine. but once I am logged in I cant see
logout button or is there a way to process logout application (may be just
by destroying session). Also please help me in pointing as in how can i
enter data in mysql once a user is logged in:
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
(function () {
var po = document.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = 'https://plus.google.com/js/client:plusone.js?onload=start';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
</script>
</head>
<body>
<div id="signinButton">
<span class="g-signin"
data-scope="https://www.googleapis.com/auth/plus.login"
data-clientid="609863033698.apps.googleusercontent.com"
data-redirecturi="postmessage"
data-accesstype="offline"
data-cookiepolicy="single_host_origin"
data-callback="signInCallback">
</span>
</div>
<div id="result"></div>
<script type="text/javascript">
function signInCallback(authResult) {
if (authResult['code']) {
// Hide the sign-in button now that the user is authorized, for example:
$('#signinButton').attr('style', 'display: none');
// Send the code to the server
$.ajax({
type: 'POST',
url: 'plus.php?storeToken',
contentType: 'application/octet-stream; charset=utf-8',
success: function(result) {
console.log(result);
if (result['profile'] && result['people']){
$('#results').html('Hello ' + result['profile']['displayName'] +
'. You successfully made a server side call to people.get and
people.list');
} else {
$('#results').html('Failed to make a server-side call. Check your
configuration and console.');
}
},
processData: false,
data: authResult['code']
});
} else if (authResult['error']) {
}
}
</script>
<script type="text/javascript">
function disconnectUser(access_token) {
var revokeUrl = 'https://accounts.google.com/o/oauth2/revoke?token=' +
access_token;
// Perform an asynchronous GET request.
$.ajax({
type: 'GET',
url: revokeUrl,
async: false,
contentType: "application/json",
dataType: 'jsonp',
success: function(nullResponse) {
},
error: function(e) {
}
});
}
$('#revokeButton').click(disconnectUser);
gapi.client.load('plus','v1', function(){
});
profile: function(){
var user = gapi.client.plus.people.get( {'userId' : 'me'} );
user.execute(function(profile)){
$('#profile').append(
$('<p><img src=\"' + profile.image.url + '\"></p>') );
$('#profile').append(
$('<p>Hello ' + profile.displayName + '</p>')
);
});
}
</script>
<div id="profile"></div>
<!-- google login ends -->
</body>
</html>
No comments:
Post a Comment