Callback in google.accounts.oauth2.initCodeClient is called with empty object

22 views Asked by At

The callback is supposed to be called with an object, containing things like authuser, code, scope, scope etc... Around 6-7 times a day, it's being called with an empty object.

async function initClient(
  callback: (googleAuthResponse: GoogleAuthResponse) => void,
) {
  try {
    return (window as any).google.accounts.oauth2.initCodeClient({
      client_id: GOOGLE_SIGNIN_CLIENT_ID,
      scope: 'openid profile email',
      callback,
      error_callback: (error: any) => {
        addAlertMessage({
          type: 'error',
          message: getGoogleErrorMessage(error),
        });
      },
    });
  } catch (err) {
    throw new Error(
      `Google Client initialization failed with error: ${JSON.stringify(err)}`,
    );
  }
}

load()
    .then(() =>
      initClient((googleAuthResponse: GoogleAuthResponse) => {
        store.dispatch(
          logInWithGoogle({ ...googleAuthResponse, ...partnerData }),
        );
      }),
    )

Can anybody recommend something? Does anybody know what's causing it?

0

There are 0 answers