one question that has been bugging me for some time. console.log (F12) gives this error:
Uncaught ReferenceError: google is not defined
at 10d93dc397bb6d8364f2defff7230c2f.js?ver=a9888:16:351
at 10d93dc397bb6d8364f2defff7230c2f.js?ver=a9888:16:556
upon checking and searching js file, i can see that:
;(()=>{async function handleCredentialResponse(response){try{const res=await fetch('https://www.viraltui.com/wp-login.php?action=googlesitekit_auth',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:new URLSearchParams(response)});if(res.ok&&res.redirected){location.assign(res.url)}}catch(error){console.error(error)}}google.accounts.id.initialize({client_id:'7myownid.apps.googleusercontent.com',callback:handleCredentialResponse,library_name:'Site-Kit'});google.accounts.id.prompt()})()
could it be that My LiteSpeed Cache Plugin is compressing all .JS including Site kit required .JS file as well.
@viraltui Thanks for sharing the console error, I will check this. With regards to the LiteSpeed Cache Plugin, we have seen issues with this plugin and other optimization plugins specifically when using JS minification. If you have this setting enabled you could try disabling it temporary and checking your site once more?
You can also try disabling the plugin altogether and checking your site once more for the one tap prompt on your site pages.
i don’t know why but i have this error lot’s time:
[30-Jan-2025 03:15:49 UTC] PHP Warning: Undefined array key "family_name" in /home/vv/public_html/wp-content/plugins/google-site-kit/includes/Modules/Sign_In_With_Google/Authenticator.php on line 261
also, i forgot to mention that i use Wordfence Free version.
@viraltui Thanks for sharing. I will discuss this with the team to explore what may be happening here and get back to you once I have an update. If you have any other information in the meantime then let me know here.
@viraltui I have discussed this with the team and they have asked if you could when possible and you’re back to share a recording of your experience with any console errors you may see at the time. I will await this information from you and continue to monitor this. Should I have an update before you make contact I will let you know here.
well i have been testing things my self.
here is the code that made my custom page Template Pages to show one tap sign in:
<!-- Sign in with Google button added by Site Kit -->
<script src="https://accounts.google.com/gsi/client"></script>
<script>
(()=>{async function handleCredentialResponse(response){try{const res=await fetch('https://www.viraltui.com/wp-login.php?action=googlesitekit_auth',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:new URLSearchParams(response)});if(res.ok && res.redirected){location.assign(res.url);}}catch(error){console.error(error);}}google.accounts.id.initialize({client_id:'mysecretzzzzzzzzid.apps.googleusercontent.com',callback:handleCredentialResponse,library_name:'Site-Kit'});google.accounts.id.prompt();})();
</script>
<!-- End Sign in with Google button added by Site Kit -->
this code does let user login/sign up, but after login they redirect to /wp-admin/ instead of redirecting to the page where user login.
can you tell me if this code is all right to use?
Most importantly can you modify the code to redirect to same page where login occurred?
As for Recording, iam hoping i will be able to give that on Sunday (2nd February).
I had to use ChatGPT, Gemini is useless (I’m a text-based AI, and that is outside of my capabilities.)
here is the code now it’s working perfectly.
<!-- Sign in with Google button added by Site Kit -->
<script src="https://accounts.google.com/gsi/client"></script>
<script>
(() => {
// Store the current page URL
const currentPage = window.location.href;
async function handleCredentialResponse(response) {
try {
// Append the return URL as a query parameter
const params = new URLSearchParams(response);
params.append('redirect_to', currentPage);
const res = await fetch('https://www.viraltui.com/wp-login.php?action=googlesitekit_auth', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: params
});
if (res.ok && res.redirected) {
location.assign(res.url);
}
} catch (error) {
console.error(error);
}
}
google.accounts.id.initialize({
client_id: '7secretid.apps.googleusercontent.com',
callback: handleCredentialResponse,
library_name: 'Site-Kit'
});
google.accounts.id.prompt();
})();
</script>
<!-- End Sign in with Google button added by Site Kit -->
Thank you for trying to help.
but even if user is logged-in it still show One tap Prompts.
all right i had to add some code in functions.php now everything is going well.