Google Sign in
Archived 2 years ago
T
flash
Verified
im trying to implement google sign in button but when you login it has a callback function but this happens here the code:
<script>
function googleAuth() {
function handleLogin(response) {
fetch("http://localhost:8080/api/login/", {
method: 'post',
credentials: 'include',
headers: {
'Authorization': response.credential,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"client_id": response.client_id,
}),
}).then(r => {
if (!r.ok) {
return r.text().then(text => console.log(`Error during login ${r.status}: ${text}`))
}
window.location.reload();
}).catch(e => {
console.log(`Error during login: ${e}`)
});
}
window.google.accounts.id.initialize({
client_id: 'id',
callback: handleLogin,
context: 'signup',
ux_mode: 'popup',
});
return null;
}
googleAuth()
</script>
Whenever I try and click anything it gives me this in the console:
VM180 client:212 Uncaught TypeError: Cannot read properties of null (reading 'parentNode')
at mp (VM180 client:212:220)
at Iq (VM180 client:257:135)
at Tq (VM180 client:255:487)
at Hq.c.port1.onmessage (VM180 client:263:156)
