Google + HTML Sign in not working on IE or Firefox
-
18-10-2022 - |
Вопрос
I'm working on a web app that uses client side authentication through the Google + API. Im using a modified example from Google that uses an HTML element with the app information and some Javascript to handle the response. In Chrome everything works great but in IE 9+ and Fierfox I cant get the authentication to kick in.
HTML:
<div id="signin-button" class="hide">
<div class="g-signin"
data-callback="loginFinishedCallback"
data-clientid="{my client id}"
data-scope="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.profile.emails.read"
data-cookiepolicy="single_host_origin"
>
</div>
Javascript:
<script src="https://apis.google.com/js/client:plusone.js" type="text/javascript"></script>
<script type="text/javascript">
var profile, email;
function loginFinishedCallback(authResult) {
if (authResult) {
if (authResult['error'] == undefined){
gapi.client.load('plus','v1', loadProfile); // Trigger request to get the email address.
} else {
console.log('An error occurred');
$( "#signin-button" ).removeClass( "hide" ).addClass( "show" );
}
} else {
console.log('Empty authResult'); // Something went wrong
$( "#signin-button" ).removeClass( "hide" ).addClass( "show" );
}
}
/**
* Uses the JavaScript API to request the user's profile, which includes
* their basic information.
*/
function loadProfile(){
var request = gapi.client.plus.people.get( {'userId' : 'me'} );
request.execute(loadProfileCallback);
}
function loadProfileCallback(obj) {
profile = obj;
email = obj['emails'].filter(function(v) {
return v.type === 'account'; // Filter out the primary email
})[0].value; // get the email from the filtered results, should always be defined.
displayProfile(profile);
}
/**
* Display the user's basic profile information from the profile object.
*/
function displayProfile(profile){...}
</script>
I should mention that I do not get any error on the console when the page loads in Firefox, IE, or Chrome.
Нет правильного решения
Не связан с StackOverflow