Google Sign-In SDK

This is a working example of how the Google Sign-In JS SDK works.

Click to see the code below working in practice!

  gapi.load("auth2", async function() {
const auth = await gapi.auth2.init({
"client_id": "__YOUR_CLIENT_ID__"

const user = await auth.signIn({
// scope by default is basic profile
scope: "profile email"

const response = user.getAuthResponse();
const {access_token, id_token} = response;
// access_token only available when extra
// scopes are passed.

// logs the user out
await auth.signOut();
// revokes
await auth.disconnect();