I've been trying to set up google oauth for the android version of the application that I'm building. Below you will find a code snippet of the initial set up that I had. I have gone through several iterations of how I've been setting up the code to work with the android version however the error that I keep getting is a URI redirect mismatch. I understand what the error means but I'm not sure what I'm doing wrong.
In the google developers console in the android section, there are 3 inputs where I can enter information.
name: this doesn't matter AFAIK
Package.name: I've tried to set this either the scheme in my app.json or the android.package name
SHA-1 Fingerprint certificate: I got this value from doing eas credentials.
I'm fairly certain that I'm screwing up the package.name input.
App.json scheme: com.john-doe.mobile-client
android.package: com.john-doe.appname_android
Im going to make the scheme and the package name the same then will rebuild. I will probably need to update the sha-1 fingerprint certificate also after a rebuild. Once the build is done I'll come back to update this but I'm honestly stumped.
import { useAuthRequest } from "expo-auth-session/providers/google";
WebBrowser.maybeCompleteAuthSession();
const [request, response, promptAsync] = useAuthRequest({
androidClientId:
"myadroid-client-id.apps.googleusercontent.com",
iosClientId:
"myios-client-id.apps.googleusercontent.com",
});
// refactor this to not use useEfffect.
useEffect(() => {
if (response?.type === "success") {
const { authentication } = response;
const accessToken = authentication?.accessToken;
if (accessToken) {
saveAuthToken(accessToken)
.then(() => refreshSession())
.then(() => router.push("/"))
.catch((error) => {
console.error("Error saving token:", error);
});
}
}
}, [response]);Expo on their page wants us to use expo-auth-session over expo-google-app-auth.
But,
The expo-auth-session flow throws an ugly / scammy looking alert to the user before going into the google auth flow in an external browser, after showing a browser selection. Users are likely to drop off at this point itself, this is bad UX.
expo-google-app-auth doesn't do this, it seems to load what looks like a webiew inline and shows a clean google account selection screen.
However if you ignore this deprecation and continue using expo-google-app-auth, there is a runtime warning like "Deprecated: You will need to use expo-google-sign-in to do server side authentication outside of the Expo client" which I find confusing. Don't you have to do server side authentication (if you need to) regardless of which solution you use?
Thoughts around this? If you use the expo managed workflow, which one did you pick? I am at a bit of a dilemma...
Videos
What happened to seamless auth integrations with expo apps?
I'm using the expo-router and supabase. I want to implement google auth and I have two options:
expo-auth-session : the docs are not up to date, for implementing google auth with supabase the docs refer to the supabase docs which uses react-native-google-signin.
react-native-google-signin : the free/original version will be deprecated in 2025 so there's no point of using this and I do not want to use their paid version.
What should I do?
Hi there! I'm working in a personal project and I want to make a log in and sign up with google, then I have been working with expo-auth-session (https://docs.expo.dev/versions/latest/sdk/auth-session/) and google cloud. The issue is that when I make log in, it never gets back to my app, everytime it redirect to google.com
I'm working in android. How can I fix this problem? did you find this issue anytime?
thanks you for advice!
Edit: My login button component is this (it's just a test, I never do it before):
WebBrowser.maybeCompleteAuthSession();
export const Login = () => {
const [request, response, promptAsync] = Google.useAuthRequest({
androidClientId: config.GOOGLE_ANDROID_CLIENT_ID,
clientId: config.GOOGLE_ANDROID_CLIENT_ID,
});
const testSending = async (token: string) => {
console.log("=========================TOKEN========================");
console.log(token);
console.log("=================================================");
};
useEffect(() => {
if (response) {
if (response.type === 'success') {
const { authentication } = response;
testSending(authentication?.idToken || '');
console.log(authentication);
}else {
console.log("=========================FAILED========================");
console.log("Login failed");
console.log("=================================================");
}
}
}, [response])
return (
<Pressable onPress={() => promptAsync().catch((error) => console.error(error))} disabled={!request} style={{ padding: 10, backgroundColor: 'blue' }}>
<Text style={{ color: 'white' }}>Login with Google</Text>
</Pressable>
)
}I’m working on integrating Google Calendar OAuth into my React Native app using Expo, and I’m running into an issue where the redirect URI returned by makeRedirectUri({ useProxy: true }) is wrong — it’s always exp://127.0.0.1:8081, even though I’m expecting the Expo proxy URI (e.g. https://auth.expo.io/@username/myapp) to be returned.
I’ve been debugging this for hours and would really appreciate any advice or insight.
Some Context:
I’m using expo-auth-session version ~5.5.2 My app is built with Expo Router and uses OAuth to Google Calendar I want to allow users to connect their Google Calendar and add events from our app I’m using web-based OAuth, not direct sign-in or server-side flows Running locally via expo & Android studio
This is my code snippet:
import { makeRedirectUri, useAuthRequest, ResponseType } from 'expo-auth-session'; import * as WebBrowser from 'expo-web-browser'; import { useEffect } from 'react'; import config from '@/config';
WebBrowser.maybeCompleteAuthSession();
const discovery = { authorizationEndpoint: 'https://accounts.google.com/o/oauth2/v2/auth', tokenEndpoint: 'https://oauth2.googleapis.com/token', };
export function useGoogleAuth() { const redirectUri = makeRedirectUri({ useProxy: true, scheme: 'my app name', });
console.log('[useGoogleAuth] redirectUri =', redirectUri);
const [request, response, promptAsync] = useAuthRequest( { clientId: config.googleClientId, scopes: ['https://www.googleapis.com/auth/calendar.events'], redirectUri, responseType: ResponseType.Code, extraParams: { access_type: 'offline', prompt: 'consent', }, }, discovery );
useEffect(() => { console.log('[useGoogleAuth] response =', response); }, [response]);
return { promptAsync, request, response }; }
And yes I added authorized uris and authorized test users in Google cloud console.
I also added the redirect URI: https://auth.expo.io/@myusername/myapp to google.
My questions: • Why is makeRedirectUri({ useProxy: true }) still giving me exp://127.0.0.1:8081? • Is there some config I’m missing in app.json, expo-router, or somewhere else? • Should I upgrade expo-auth-session or use a different method to get the correct proxy URI?
Thanks
Hello everyone, im trying to implement google sign in to my app, but i cant make it work on my build (expo go is working). So far i've tried enabling custom uri schemes on google console but after signin nothing happens, the app just keeps on loading. I've tried adding a redirectUri but that gets me the error "Error 400: invalid_request", Details: "redirec_uri=exp://my-slug-here". So my question is, how can i set up this properly? Any help is really appreciated, here's my code:
import * as WebBrowser from "expo-web-browser";
import * as Google from "expo-auth-session/providers/google";
import * as AuthSession from 'expo-auth-session';
const redirectUri = AuthSession.makeRedirectUri({
useProxy: false,
native: 'exp://slug-here',
});
const [request, response, promptAsync] = Google.useIdTokenAuthRequest({
clientId:
"clientId",
androidClientId: "androidId",
redirectUri
});
Hey,
I'm stuck on what should be a pretty standard setup: Google Sign-In using Supabase + expo-auth-session in a React Native app (EAS build, TestFlight) — and I keep getting a 400 error (invalid_request) when trying to sign in.
Here’s my setup:
expo-auth-session/providers/google
supabase-js@2react-nativeEAS Build (production)
TestFlight (not Expo Go)
supabase.auth.signInWithIdToken({ provider: 'google', token })
Google Cloud config:
Created a client ID for iOS
Bundle ID, App Store ID and Team ID are set correctly
Scopes enabled:
openid,email,profile. All three are visible under “Non-sensitive scopes”
Supabase config:
Google provider enabled
Client ID = the iOS one above
Callback URL (non-editable):
https://xxxxx.supabase.co/auth/v1/callback
const redirectUri = makeRedirectUri({
native: '*myapp*://oauthredirect',
useProxy: false,
});
const [request, response, promptAsync] = Google.useAuthRequest({
clientId: ENV.GOOGLE_IOS_CLIENT_ID,
scopes: ['openid', 'profile', 'email'],
redirectUri,
});
App scheme is correctly set in
app.jsonandInfo.plistResponse returns
type: success, but Google blocks the flow and shows:
"Error 400: invalid_request
redirect_uri=myapp://oauthredirect
This app doesn't comply with Google OAuth policies."
What I’ve tried:
Triple-checked bundle ID, scopes, and redirect URI
Registered everything as expected in both Google Cloud and Supabase
Used only native redirect (no
useProxy)No Expo Go — only TestFlight builds
Enabled the iOS client in Supabase with correct client ID
Would love any guidance been stuck for days. Thanks 🙏
Hi guys, I’m trying to use expo AuthSession to allow a user to sign into my app using Google, I’ve got this working which returns a token with which I can get the user details. But what are the next steps, how will my backend validate this Google token/know which assets in my DB belong to this user?
I wanted to do this using strapi as I just wanted to create a simple mock backend for now and strapi has a Google plugin but it asks for a redirect url flow which Expo AuthSession already handles.
Thanks
Title means to say: Strapi
What did work?
Do you have public source code for working ones? - Could you share them?
I've encountered a challenge with Expo and Google authentication. It seems that Expo's AuthSession
is deprecated, and attempts to use the u/react-native-google-signin/google-signin
library in Expo Go lead to issues due to custom native code requirements.
I'm eager to know if Google authentication is still possible in Expo, or if it's restricted to bare React Native projects. If it's achievable in Expo, could anyone provide insights or suggest a guide on the recommended approach?
I appreciate any guidance or experiences shared by the community.
Hello guys new to react native here how do you setup Google auth using expo any guides or documentation Available. I am using expo go app as a simulation
I’m trying to set up google auth with react native (expo). I’m using signInWithOAuth, and it is working in that the user can sign in and a row is created as an authenticated user in supabase.
However, my _layout file uses supabase.auth.onAuthStateChange , and then if there is a session, it redirects the user to the home page, and if there isn’t a session, it redirects them to the welcome page.
However, when I use signInWithOAuth, it doesn’t create a session in supabase, so onAuthStateChange cannot find a session.
What is the best way to go about this? How do I create a session in supabase when I use google sign up????
So yeah, hitting a wall here.
I’m trying to set up Google login in my Expo React Native app using expo-auth-session
The issue → redirect URI keeps blocking me. Google keeps throwing the “Authorization Error / redirect_uri_mismatch” thing.
What I’ve done so far:
-
Set the redirect URIs in Google Cloud console (double-checked them like 100x 🙃)
-
Scraped through YouTube tutorials, blog posts, random Github issues
-
Even tried adding different variations of the redirect URI manually
-
Still stuck.
I don’t want to use a dev build just for this (my setup is still Expo managed).
👉 Is there any way to set this up properly without ejecting / going full dev build?
If anyone has done Google auth with expo-auth-sessionrecently and has some working setup, would really appreciate pointers 🙏. Also want to know how to set this if I am moving to production.
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(
"https://www.googleapis.com/userinfo/v2/me",
{
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>
);
}
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(
"https://www.googleapis.com/userinfo/v2/me",
{
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>
);
}I'm working on a project where I need to implement the social auth in a mobile app, the thing is I'm stuck in the auth with expo sdk 46 web based (expo-auth-session), if any one could point me to some help tutorial article that is up to date.
i found solutions that forces me to go bare expo and that will break the real point of using expo.
Sorry if it seems hectic I'm just a junior dev with some experience in react only, in the start I really enjoyed react native and looked to me so similar to react.js but know the differences are starting to come.
Thank you for your help in advance.
So I noticed I warning few days ago in my play console saying the GoogleSignIn will be deprecated in 2025 and so I rushed to migrate to the new Credential Manager.
Before, I used the free version of react-native-google-signin which doesn't support the new Credential Manager sign in, only the sponsored one does, apparently. So I found a package that does - heartbot/expo-google-authentication/expo-google-authentication.
What I noticed that, there's no SilentSignIn method anymore, apparently Credential Manager doesn't support it anymore, which is a bummer, since it was a seamless way to refresh the idToken before doing my authenticated backend calls. Right now there are two ways to sign in the user:
login()method - which you use when the user shows intent to login, for example by pressing a login button. When initiated it shows a modal with your accounts to select from.loginWithoutUserIntent()method - when called, shows a bottom sheet that slides up. If the user only has one google account, it automatically logins with that account and the bottom sheet closes. If there's more than one account, the user must select which account they want to login with.
So instead of SilentSignIn I must now call loginWithoutUserIntent() every hour (idToken is valid for 1 hour) which is not ideal, as you can imagine.
I really, really don't want to create a complicated custom authentication flow for my app just for a valid auth token, so I will keep it as is for now, which is using the old GoogleSignIn, but ready to push the new one with Credential Manager to play store if need be.
What I wonder is, if the deprecated GoogleSignIn will stop working in 2025 and all the apps using it will have to be updated, or will it continue working as the dev of react-native-google-signin implies.
Recently I have started a project that involves OAuth I am able to reach the project I set up on google using this guide: https://docs.expo.io/guides/authentication/#google, but I do not know how exactly to communicate with my RoR backend.
Currently if I sign in using the google the web browser dismisses but I am still on my sign in page. I need some way to pass credentials back to my app
Hello everyone, im trying to implement google sign in to my app, but i cant make it work on my build (expo go is working). So far i've tried enabling custom uri schemes on google console but after signin nothing happens, the app just keeps on loading. I've tried adding a redirectUri but that gets me the error "Error 400: invalid_request", Details: "redirec_uri=exp://my-slug-here". So my question is, how can i set up this properly? Any help is really appreciated, here's my code:
import * as WebBrowser from "expo-web-browser";
import * as Google from "expo-auth-session/providers/google";
import * as AuthSession from 'expo-auth-session';
const redirectUri = AuthSession.makeRedirectUri({
useProxy: false,
native: 'exp://slug-here',
});
const [request, response, promptAsync] = Google.useIdTokenAuthRequest({
clientId:
"clientId",
androidClientId: "androidId",
redirectUri
});