如何在不使用react-native-google-signin/google-signin的情况下使用Firebase、Expo SDK 49和Google Signin?

问题描述 投票:0回答:1

似乎通过 Expo Go 在移动应用程序中实现 Google 身份验证已更改,并且文档似乎说需要

@react-native-google-signin/google-signin
,但我无法使用
@react-native-google-signin/google-signin
,因为它需要 Expo SDK 50,并且我的一些依赖项不兼容使用 SDK 50(我使用的是 SDK 49)。

我尝试过使用我认为是 Google Auth 的旧方法,但它不起作用并导致

Error 400: invalid_request
。我希望能够像这样使用
GoogleAuthProvider
中的
firebase/auth

 const [request, response, promptAsync] = Google.useAuthRequest(
        {
            clientId: '',
            iosClientId: '',
            androidClientId: '',
            expoClientId: ''
        },
        Google
    );

    useEffect(() => {
        console.log(response?.type)
        if (response?.type == "success") {
            const { id_token } = response.params;
            const credential = GoogleAuthProvider.credential(id_token);
            signInWithCredential(null, credential)
        }
    }, [response]);

在我看来,我需要为 app.json 中的

googleServicesFile
指定我的 plist 和 json 文件,但这对我来说没有意义,因为它们需要使用不同的应用程序,并且我的 Firebase 身份验证位于网络应用程序。所有的教程和在线教程要么已经过时,要么使用
@react-native-google-signin/google-signin
。欢迎提出任何建议,我只是希望能够使用
signInWithCredential
而不是
@react-native-google-signin/google-signin
处理它的方式。

node.js firebase expo google-oauth
1个回答
0
投票

在移动设备上,大多数“社交登录”都需要使用本机 API。由于 Expo Go 没有内置那些本机 API(或利用它们的 NPM 模块),因此您需要构建一个自定义客户端。

...如果您计划分发您的应用程序,您无论如何都必须在某个时候执行此操作。我在这里写了一篇关于此的文章

由于您正在使用 Firebase,我建议您考虑使用

@react-native-firebase
及其受 Firebase 身份验证支持的登录提供程序。

© www.soinside.com 2019 - 2024. All rights reserved.