Its my first time doing Oauth authentication with expo, and im only running the app on android and when i try to authenticate with google i get the following error:
You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy for keeping apps secure.
also from the documentation i dont understand at all what should be the redirect_uri
and thats probably the problem, i cant find an absolute answer of what should be the redirect_uri
thats my code:
import React, { useEffect, useState } from "react";
import { Button, Text, View } from "react-native";
import * as AuthSession from "expo-auth-session";
import * as Google from "expo-auth-session/providers/google";
import * as SecureStore from "expo-secure-store";
export default function App() {
const [user, setUser] = useState(null);
const [request, response, promptAsync] = Google.useAuthRequest({
androidClientId: process.env.EXPO_PUBLIC_ANDROID_GOOGLE_CLIENT_ID,
selectAccount: true,
redirectUri: "com.anonymous.pystart://oauth2redirect"
});
useEffect(() => {
if (response?.type === "success") {
const { authentication } = response;
handleLogin(authentication?.accessToken);
}
}, [response]);
async function handleLogin(token: string | undefined) {
const userInfoResponse = await fetch(
";,
{
headers: { Authorization: `Bearer ${token}` },
}
);
const userInfo = await userInfoResponse.json();
setUser(userInfo);
await SecureStore.setItemAsync("userToken", token);
}
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
{user ? (
<Text>Welcome, {user.name}</Text>
) : (
<Button
title="Sign in with Google"
disabled={!request}
onPress={() => promptAsync()}
/>
)}
</View>
);
}