I simply followed the instructions on the homepage of Google's Identity sign-in instructions and it doesn't work.
I went to dev console, established the OAuth2.0 creds, and I'm using an express server with Passport. Basically following every tutorial you see on the web. However, when I run the code, it will open up with a OAuth2 loading and then immediately closing. No error messages or logs. And I'm still not signed in. Looking into the cookies, I see it populated with my data, however, the onSignIn function is not fired. I don't know if im signed in properly or not. Am i supposed to take the data from the cookies? Signing out of google allows the OAuth2 to stick around for a little while to allow me to sign in before immediately closing and doing nothing.
The button doesnt allow the user to sign in. It just pops up that OAuth and immediately disappears. Has anyone else had this problem? Thanks for any help!
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="google-signin-scope" content="profile email">
<script src="https://apis.google.com/js/platform.js" async defer></script>
<meta
name="google-signin-client_id"
content="CLIENT_ID.apps.googleusercontent.com"
/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Login</title>
</head>
<body>
<h1>Login</h1>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
<script>
function onSignIn(googleUser) {
var id_token = googleUser.getAuthResponse().id_token
console.log("id_token: ",id_token);
}
</script>
</body>
</html>
Ps. the client ID IS my Id. For security purposes, I excluded it