Getting Expo Auth session proxy Error when trying Login with Google in React Native

I am trying to implement Login with Google with expo-auth-session, and I am using below version:

  • “expo-auth-session”: “^4.0.3”
  • “expo-web-browser”: “^12.1.1”,

Below is my app.js code:

import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, View, Text, Image, Button } from 'react-native';
import * as Google from 'expo-auth-session/providers/google';
import * as WebBrowser from 'expo-web-browser';

WebBrowser.maybeCompleteAuthSession();

export default function App() {
  const [accessToken, setAccessToken] = React.useState();
  const [userInfo, setUserInfo] = React.useState();
  const [message, setMessage] = React.useState();

  const [request, response, promptAsync] = Google.useAuthRequest({
    androidClientId: "*********************************************",
    iosClientId: "*********************************************",
    expoClientId: "*********************************************"
  });

  React.useEffect(() => {
    setMessage(JSON.stringify(response));
    if (response?.type === "success") {
      setAccessToken(response.authentication.accessToken);
    }
  }, [response]);

  async function getUserData() {
    let userInfoResponse = await fetch("https://www.googleapis.com/userinfo/v2/me", {
      headers: { Authorization: `Bearer ${accessToken}`}
    });

    userInfoResponse.json().then(data => {
      setUserInfo(data);
    });
  }

  function showUserInfo() {
    if (userInfo) {
      return (
        <View>
          <Image source={{uri: userInfo.picture}} />
          <Text>Welcome {userInfo.name}</Text>
          <Text>{userInfo.email}</Text>
        </View>
      );
    }
  }

  return (
    <View >
      {showUserInfo()}
      <Button 
        title={accessToken ? "Get User Data" : "Login"}
        onPress={accessToken ? getUserData : () => { promptAsync({useProxy: false, showInRecents: true}) }}
      />
      <StatusBar style="auto" />
    </View>
  );
}

Error I am getting:

Error: Cannot use the AuthSession proxy because the project full name is not defined. Prefer AuthRequest (with the useProxy option set to false) in combination with an Expo Development Client build of your application. To continue using the AuthSession proxy, specify the project full name (@owner/slug) using the projectNameForProxy option.

Any support is appreciated.

Hey @neetesh, are you using a development build or Expo Go for testing your app?

If you are using Expo Go, I’d suggest using development build. Also, expoClientId you don’t need expoClientId anymore as stated in docs here: Authentication with Google and AuthSession API - Expo Documentation

For native/standalone apps and development builds, androidClientId and iosClientId are fine.

1 Like

Thanks @amanhimself, I have check the same code in development build and it is working.

Any suggestion on “Login with LinkedIn”, Please suggest.

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