'Issues with Expo Auth Session implementation

I am having issues with the implementation of Expo Auth Session.

I am trying Google Oauth Login in Expo Auth Session as documented here: https://docs.expo.io/guides/authentication/#google

WebBrowser.maybeCompleteAuthSession();

const GoogleButton = () => {
  // Endpoint
  const discovery = useAutoDiscovery('https://accounts.google.com');

  // Request
  const [request, response, promptAsync] = useAuthRequest(
    {
      clientId: 'MYID',
      scopes: ['email', 'profile'],
      // For usage in managed apps using the proxy
      redirectUri: makeRedirectUri({
        // For usage in bare and standalone
        native: 'com.googleusercontent.apps.MYID://redirect',
        useProxy: true,
      }),
    },
    discovery,
  );

  console.log(request);
  console.log(response);

  return (
    <Button
      onPress={promptAsync}
      icon={GoogleIcon}
    />
  );
};

The browser opens, I can successfully log in with google, but when I get redirected to the app, response resolves to Object { "type": "dismiss", }

I also tried implementing oauth with a different oauth service:

WebBrowser.maybeCompleteAuthSession();

const HiveButton = () => {
  // Endpoint
  const discovery = {
    authorizationEndpoint:
      'https://hivesigner.com/login-request/my.app',
  };

  // Request
  const [request, response, promptAsync] = useAuthRequest(
    {
      scopes: ['posting'],
      // For usage in managed apps using the proxy
      redirectUri: makeRedirectUri({
        useProxy: true,
      }),
    },
    discovery,
  );

  console.log(request);
  console.log(response);

  return (
    <Button
      onPress={promptAsync}
      icon={HiveIcon}
    />
  );
};

The browser opens, I can log in successfully, but instead of being redirected to the app, I get "Something went wrong trying to finish signing in. Please close this screen to go back to the app." on auth.expo.io/@me/myapp, even though the parameter code has the correct login token that I want to pass to my app.



Solution 1:[1]

Try this:

-Login to your expo account: on command line type:

expo login
##then your account credencials##

then restart your expo instance:

expo start

And everything should work fine

Solution 2:[2]

I have the exact same issue. I've posted on the Expo forums too and tried to contact the devs about it but nobody's responding to me. I think it's been broken with a recent change. If you look at the redirect URL it's supposed to have two more query parameters one for the authentication URL and one for the return URL

Solution 3:[3]

I’ve now solved the second issue by using AuthSession.startAsync instead:

 const handleLogin = async () => {
    const redirectUrl = AuthSession.getRedirectUrl({ useProxy: true });
    const response = await AuthSession.startAsync({
      authUrl: `https://hivesigner.com/login-request/my.app?redirect_uri=${redirectUrl}&scope=posting`,
    });
console.log(response)
}

Instead of using AuthSession for Google login I’m using the expo-google-sign-in implementation

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 paichato
Solution 2 Sean O'Leary
Solution 3 Julian