-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expo-auth-session with Google login problems in Development build on android #18270
Comments
Hi @sikandarchishty - I believe that for now, unfortunately, to use We could definitely do a better job of documenting this! If you're able to confirm this works for you then I will go ahead and update our docs to reflect this. |
Hi @esamelson - I am also having this issue. I got the authentication to work in Expo Go using the makeRedirectUri() like you said, but when I tried the native option in the dev client I am getting an error on the Google sign in page. I'm getting the same behavior with both iOS and Android, and I am on SDK 46.
Here's my relevant code excerpt:
and my app.json has a scheme in it as follows:
|
Hi @duggster -- I believe you'll need to follow the instructions here for setting up Google auth for iOS / Android native apps, including the piece where the scheme must match your app's bundle identifier. (Everywhere it says "bare workflow" in that doc applies to development builds as well.) Let me know if that helps. |
I should mention I'm in managed workflow as well, and I already had my OAuth Client IDs set up and working fine with Expo Go, dev clients and in production on SDK 45 (and the Google Client's Bundle ID already matches my app.json ios.bundleIdentifier, as well as the Google Client's Package name matches my app.json android.package). This issue just started happening after I recently upgraded to SDK 46 and started testing everything. I went through the steps again from the instructions, however when I get to the command Are there any other files/config that would help for me to post? |
So the Google login does indeed work when I changed my app.json scheme to match my bundle identifier: "com.myapp.myapp", and then in the code for the native parameter as well:
And run another dev-client build, and it's able to authenticate successfully. |
@sikandarchishty I'm experiencing the same issue on android. Did you ever find a work around. Also @esamelson - i tried utilizing your recommendation:
My implementation: environment: development build (testing internally on google play store) const redirectUri = makeRedirectUri({
useProxy: USE_PROXY==='false' ? false : true,
scheme: 'swade',
path: '/auth'
});
const googleConfigs = {
androidClientId: GOOGLE_ANDROID_ID,
iosClientId: GOOGLE_IOS_ID,
expoClientId: GOOGLE_PROXY_ID,
}
const [request, response, promptAsync] = Google.useAuthRequest(
googleConfigs,
redirectUri
);
useEffect(async () => {
if (response?.type === "success") {
await getUserData(response.authentication.accessToken);
}
}, [response]); And the results are still the same - maybe I'm missing something? Still no errors or crashes. |
Did you find a solution to this ? |
@raphaelobinna I was able to get it working in production but not in dev (i.e. does not work in expo-go app). This was my full implementation: WebBrowser.maybeCompleteAuthSession();
const EXPO_REDIRECT_PARAMS = { useProxy: true, projectNameForProxy: '@swade-io/swade' };
const NATIVE_REDIRECT_PARAMS = { native: "com.swade.swade://" };
const REDIRECT_PARAMS = Constants.appOwnership === 'expo' ? EXPO_REDIRECT_PARAMS : NATIVE_REDIRECT_PARAMS;
const redirectUri = AuthSession.makeRedirectUri(REDIRECT_PARAMS);
function GoogleButton(props) {
const googleAuthUrl = `${API_URL}/v1/auths/google`
const [next, setNext] = useState(null)
const [loading, setLoading] = useState(false);
const navigate = useNavigate();
const [request, response, promptAsync] = Google.useAuthRequest({
expoClientId: GOOGLE_PROXY_ID,
iosClientId: GOOGLE_IOS_ID,
androidClientId: GOOGLE_ANDROID_ID,
redirectUri
});
const removeNext = async () => {
await AsyncStorage.removeItem('@next')
return
}
useEffect(() => {
if (response?.type === "success") {
getUserData(response.authentication.accessToken);
}
}, [response]);
useEffect(() => {
if (props?.next){
setNext(props.next)
}
return
}, [props?.next])
const getUserData = async (token) => {
setLoading(true)
props.callBack(true)
await axios.post(googleAuthUrl, {'token': token})
.then((r) => {
// save data in store
var person = r.data
store.dispatch(
authSlice.actions.setAuthTokens({
access: person.user.access,
refresh: person.user.refresh,
})
);
store.dispatch(
authSlice.actions.setAccount(person.user.user)
);
store.dispatch(
authSlice.actions.setUserAccount(person.customer)
)
// decide where to navigate user
if (person.auth_type === 'login'){
if (person.customer.active){
removeNext()
setLoading(false)
props.callBack(false)
navigate(`${next ? next : '/'}`);
}else{
setLoading(false)
props.callBack(false)
navigate('/phone')
}
}else{
props.callBack(false)
setLoading(false)
navigate('/phone')
}
})
.catch((e) => {
console.log(e)
props.callBack(false)
setLoading(false)
})
}
const authGoogle = async () => {
await promptAsync(REDIRECT_PARAMS)
}
return (
<View className='flex flex-row justify-center w-full my-4' >
<Pressable
className={`w-[80%] h-12 rounded-xl ${loading ? 'bg-slate-300/50' : 'bg-white'} pt-4 flex-0 flex-row justify-center`}
disabled={loading}
onPress={authGoogle}
shadowColor='gray'
style={{
borderRadius: 35,
shadowColor: '#000',
shadowOffset: { width: 0, height: 1 },
shadowOpacity: 0.2,
shadowRadius: 2,
elevation: 5
}}
>
<View className='w-[80%] flex flex-row justify-evenly'>
<Image
source={google_logo}
style={{
width: 20,
height: 20,
}}
/>
<Text className='text-md font-semibold text-slate-800 text-center my-auto'>
Continue With Google
</Text>
</View>
</Pressable>
</View>
);
} |
Facing this issue after migrating from 45 to 47 expo sdk. |
same, mine was from 45 to 46 |
Quick question for the scheme did you use "com.app.app://" |
Yeah without the :// |
Am able to make it work on dev wasn't passing |
Might create an example and link it here for anyone to save them time especially if they are migrating to 47. For me the error was |
I am having the same error after migrating 45 to 46 version. |
same , sdk 47.0.0 |
I'm having a similar Issue on SDK 47.0.0 - The app works fine on Expo Go, but as soon as I build and run on testflight, or run with the folllowing command
Code is here:
|
**### Hi, I'm having the same issue, App works Fine on Expo Go, but as I switch to Development, it won't work. it's only giving a prompt, and returning to the main screen, but not returning any object.** ` const [accessToken, setAccessToken] = useState(); const [request, response, promptAsync] = Google.useAuthRequest({ useEffect(() => {
}, [response]); useEffect(() => {
}, [response]); const logout = async () => {
};` |
Yeah this worked great before but hey lets replace it with some other shit that doesn't work at all, thanks... |
Please fix this!!!!111 |
Facing same issue |
I had the same issue. Works in the Expo Go app, but not on my android .apk. What fixed it for me was forcing to exchange the access token (also be sure to add the schemes and such https://docs.expo.dev/versions/latest/sdk/auth-session/#usage-in-standalone-apps): import Constants, { ExecutionEnvironment } from "expo-constants";
const [request, response, promptAsync] = Google.useIdTokenAuthRequest({
expoClientId: GOOGLE_PROXY_ID,
iosClientId: GOOGLE_IOS_ID,
androidClientId: GOOGLE_ANDROID_ID,
// ADD THIS TO FORCE THE AUTO EXCHANGE CODE TO GET THE ACCESS TOKEN ONLY WHEN NOT USING THE EXPO GO APP
shouldAutoExchangeCode:
Constants.executionEnvironment !== ExecutionEnvironment.StoreClient
? true
: undefined,
});
useEffect(() => {
if (response?.type === "success") {
const { id_token } = response.params;
console.log(response);
}
}, [response]); I verified this with Expo v47 and v48 and using auth package ("expo-auth-session": "~4.0.3",). Hopes this helps! |
any update with this ? this is 2023 and i cant find a solution |
Encountering this in v3.7.4 and expo 46. It works properly on all platforms except android release apk build where it doesn't return any response after logging in via prompt. Seems like many others are also experiencing this bug. |
Same issue with expo 48 on android only. It works on iOS but on android there's no redirect to the app after logging in |
@imarc7 that means your setup is incorrect. Your android schema name has to match package name which you then use in redirect uri. So basically:
|
Do have any change ?? |
Hey guys! Do we have anything new? I'm using SDK 48 and getting the error: "Access blocked: This app's request is invalid. Error: 400: redirect_uri_mismatch" This error only occurs when I generate the build (apk) through Expo Go and the Web works. My code: `/* eslint-disable prettier/prettier */ WebBrowser.maybeCompleteAuthSession(); const AuthScreen = () => { const [request, response, promptAsync] = Google.useAuthRequest({ const handleUserInfo = async () => { useEffect(() => { function showUserInfo() { return ( const styles = StyleSheet.create({ ` |
I'm also facing this issue:
Have followed the setup:
|
We've deprecated Google auth provider from |
@amandeepmittal the library seems to have issues on react-native-web. I find it quite weird to suggest an experimental library which the owner states that he will not fix bugs :( |
Try to change "expo-auth-session" version to "^4.0.3". And code: const signin = async () => { It works for me. |
Summary
hi,
Loggin in with expo-auth-session works absolutely fine in Expo Go App but as soon as .apk is built, the login workflow opens the signin page and then closes after the login is complete but the response vanishes and does not do anything, but this happens only in .apk but works fine in Expo Go App.
Managed or bare workflow? If you have made manual changes inside of the
ios/
orandroid/
directories in your project, the answer is bare!managed
What platform(s) does this occur on?
Android
Package versions
"expo-auth-session": "~3.6.1",
Environment
System:
OS: macOS 12.4
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.1 - /usr/local/bin/node
npm: 8.11.0 - /usr/local/bin/npm
Watchman: HEAD-317a5eb - /opt/homebrew/bin/watchman
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
IDEs:
Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
npmPackages:
expo: ~45.0.0 => 45.0.6
react: 17.0.2 => 17.0.2
react-dom: 17.0.2 => 17.0.2
react-native: 0.68.2 => 0.68.2
react-native-web: 0.17.7 => 0.17.7
npmGlobalPackages:
eas-cli: 0.54.1
expo-cli: 5.5.1
Expo Workflow: managed
Reproducible demo
Stacktrace (if a crash is involved)
No response
The text was updated successfully, but these errors were encountered: