简体   繁体   English

在 android 上的开发中出现 Google 登录问题的 expo-auth-session

[英]expo-auth-session with Google login problems in Development build on android

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, this happens only in.apk but works fine in Expo Go App.使用 expo-auth-session 登录在 Expo Go 应用程序中工作得非常好,但是一旦构建了.apk,登录工作流程就会打开登录页面,然后在登录完成后关闭,但响应消失并且不执行任何操作,这仅在.apk 中发生,但在 Expo Go 应用程序中工作正常。

const config = {
  expoClientId: "some value",
  iosClientId: "some value",
  androidClientId: "some value",
};

const [user, setUser] = useState(null);

const [request, response, googlePromptLogin] = Google.useAuthRequest(config);

useEffect(() => {
    if (response?.type === "success") {
        async function SignIn() {
            const credential = GoogleAuthProvider.credential(
                null,
                response.authentication.accessToken
            );
            await signInWithCredential(auth, credential);
        }

        SignIn();
    } 
    else {
        console.log("not logged in");
    }
}, [response]);

useEffect(() => {
  onAuthStateChanged(auth, (user) => {
    if (user) {
      setUser(user);
    } else {
      setUser(null);
    }
  });
}),
  [];


// Button
<Button onPress={googlePromptLogin} title="Login"/>

You could try setting the "scheme" property in your app.json file.您可以尝试在 app.json 文件中设置“方案”属性。 The schema must be the same as the assigned "package" name for Android.架构必须与为 Android 分配的“包”名称相同。 That worked for me.这对我有用。

{
  "expo": {
    "name": "NewApp",
    "scheme": "com.myname.mycoolapp",
    "android": {
      "package": "com.myname.mycoolapp",      
    }
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以通过 expo-auth-session/providers/google 获取 access_token? - Is it possible to obtain an access_token with expo-auth-session/providers/google? Firebase React Native Expo 谷歌登录错误 - Firebase React Native Expo login error with google Expo Android 构建未打开 - Expo Android Build Doesn't Open Google Auth 仅在 Android 上出了点问题 - Something went wrong with Google Auth only on Android Facebook 和 Google 登录不适用于 Android AAB 构建上传到 Firebase 应用程序分发 - Facebook and Google login doesn't work for Android AAB build uploaded to Firebase App Distribution 苹果登录 android FireBase Auth 有问题 - Apple login in android with FireBase Auth has problem 如何连接Firebase Auth和Google One Tap Login - How to Connect Firebase Auth with Google One Tap Login 在 Google Workspace 插件中保留 Firebase Auth session - Persist Firebase Auth session in Google Workspace Add-on 您可以使用某人的 google play 帐户进行 Firebase 身份验证和 Google 登录吗? - Can you use someone's google play account for Firebase Auth with Google login? 谷歌云 SDK:gcloud auth login 给我一个错误 - Google Cloud SDK: gcloud auth login gives me an error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM