lundi 29 décembre 2014

Google Plus Sign-In button rendered but not working

I'm trying to get comfortable with the Google APIs.


To study the sign-in process, I built a simple web page to get the sign-in button working according to https://developers.google.com/+/web/signin/add-button and the button is rendered properly. However, it is not active - it doesn't react to clicks, there's also no error in the browser console.


I do not run the page from a web server, I'm opening it directly from disk. I.e. the URL is something like file:///c:/projects/GooglePlusClientJS/google_plus_js.html.


The page code:



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">

<script src="https://apis.google.com/js/client:platform.js" async defer></script>
<script type="text/javascript">
function signinCallback(authResult) {
if (authResult['status']['signed_in']) {
// Update the app to reflect a signed in user
// Hide the sign-in button now that the user is authorized, for example:
console.log("Signed in");
document.getElementById('signinButton').setAttribute('style', 'display: none');
} else {
// Update the app to reflect a signed out user
// Possible error values:
// "user_signed_out" - User is signed-out
// "access_denied" - User denied access to your app
// "immediate_failed" - Could not automatically log in the user
console.log('Sign-in state: ' + authResult['error']);
}
}
</script>
<title>GooglePlus Test</title>
</head>
<body>

<span id="signinButton">
<span
class="g-signin"
data-callback="signinCallback"
data-clientid="1014595779278-cp57erbq6libuesalb18reuqcmco37ab.apps.googleusercontent.com"
data-cookiepolicy="none"
data-requestvisibleactions="http://schema.org/AddAction"
data-scope="https://www.googleapis.com/auth/plus.login">
</span>
</span>

</body>
</html>


What am I doing wrong? Is it caused by opening it directly from disk? If so, why?


Thanks.





Aucun commentaire:

Enregistrer un commentaire