I have had the same issue, have managed to get it working using expo-dev-client.
I didn't find a way to fix this for Expo Go - not sure if there is one currently. It seems like using Oauth google login on IOS, currently requires building the app.
Once you configure the build, you can use
import { makeRedirectUri } from 'expo-auth-session';
to get the correct redirect URL.
const [request, response, promptAsync] = Google.useAuthRequest({
clientId: 'xxxx',
iosClientId:
'xxxx',
redirectUri: makeRedirectUri()});
Also remember to generate IOS credentials in the google console.
Answer from bonbonvoyage on Stack OverflowVideos
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]);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?
So it's possible to get the idToken if you that's all you are looking for. You need to modify your code like this:
const [request, response, promptAsync] = Google.useAuthRequest({
*responseType: "id_token",*
expoClientId: 'my-expo-id',
iosClientId: 'my-ios-id',
});
You will also have to access the "params" key rather than "authentication," which will show mostly null :). For me it works at least since the rest of the information was useless. HTH!
Edit: I realized that I need to get an Access Token to use google drive in my app, and thus now I need both tokens and submitted a bug report here https://github.com/expo/expo/issues/12808 to try to get this resolved.
You can get user details like this:
First, get the access token from the response:
const accessToken = response.authentication.accessTokenSend GET request to the following endpoint with the accessToken you obtained in step 1:
axios.get('https://www.googleapis.com/oauth2/v3/userinfo?
access_token='+ACCESS-TOKEN-HERE)
.then(function(response){
const userDetails = response.data
console.log(userDetails)
})
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
});
» npm install expo-auth-session