Expo.Google.logInAsync

Here is the login flow of my application.

First, application will get access_token and serverAuthCode from Google OAuth2
Second, app will submit these infos to the backend
Third, backend will submit data to the Google OAuth2 to fetch necessary informations.
And then it will generate jwt and will return it to the app.

Here’s the code implementation of how I did it.

const result = yield call(Expo.Google.logInAsync, {
        androidClientId: androidGoogleClientId,
        iosClientId: iosGoogleClientId,
      });
      const { serverAuthCode: authCode } = result;
      const authInfo = yield call(
        ssoLogin,
        authCode,
        type,
        Platform.OS === 'ios' ? iosGoogleUri : androidGoogleUri,
        Platform.OS === 'ios' ? iosGoogleClientId : androidGoogleClientId,
      );

This is the code implementation of ssoLogin

export const ssoLogin = (authCode, type, redirectUrl, clientId) => axios
  .post(
    `${cfg.API_BASE_URL}sl_users/login/`,
    {
      auth_code: authCode,
      type,
      redirect_uri: redirectUrl,
      client_id: clientId,
    },
    {
      headers: {
        'Content-Type': 'application/json',
      },
    },
  )
  .then(response => response.data)
  .catch(err => ({
    failed: true,
    err,
  }));

In here I could get correct response from the Google OAuth2.
But the problem is that I can’t set correct return url.
This causes the Google OAuth2 to return invalid_grant error.

I need help on this issue asap.

I really appreciate your help, guys

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.