I have an app that uses google to login.
My code looks like this
import { StyleSheet, Text, View, Button,Platform } from 'react-native';
import React, { useEffect, useRef, useState } from 'react';
import { useNavigation } from '@react-navigation/native';
import * as WebBrowser from 'expo-web-browser'
import * as Linking from "expo-linking"
import * as Google from 'expo-auth-session/providers/google';
import {
makeRedirectUri,
useAuthRequest,
useAutoDiscovery,
exchangeCodeAsync,
AuthSessionResult,
} from 'expo-auth-session';
WebBrowser.maybeCompleteAuthSession();
/**
if (Platform.OS==='android') {
googleLoginConfig.redirectUri = 'https://auth.expo.io/@suqinc/kekedl';
}
/**
if (Platform.OS === 'android') {
googleLoginConfig.redirectUrl = 'urn:ietf:wg:oauth:2.0:oob';
}
*/
const Home = ({ navigation }) => {
const [token, setToken] = useState('');
const [userInfo, setUserInfo] = useState(null);
const [request, response, promptAsync] = Google.useAuthRequest({
expoClientId: '',
androidClientId:'',
iosClientId:'',
redirectUri: makeRedirectUri({ useProxy: true })
},{ useProxy: true });
useEffect(() => {
if(response?.type==='success'){
setToken(response.authentication.accessToken);
getUserInfo();
}
}, [response, token])
const getUserInfo = async () => {
try {
const response = await fetch(
"https://www.googleapis.com/userinfo/v2/me",
{
headers: { Authorization: `Bearer ${token}` },
}
);
const user = await response.json();
setUserInfo(user);
} catch (error) {
console.log('get user info error: ', error);
}
};
I am able to log the user in but on android apk the popup cannot close. On expo client everything works fine.
What could be the problem?.