我的应用程序显示谷歌登录面板,我更改了代码中的电子邮件和客户端ID,然后收到此错误

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

我正在使用 google sso

react-native-google-signin/google-signin

错误是:

{"nativeStackAndroid":[],"userInfo":null,"message":"不可恢复 登录失败","code":"12500"}

在更改客户端 ID 之前,代码运行良好: `

const googleSignIN = () => {
GoogleSignin.configure({
androidClientId: CLIENT_ID
})

    GoogleSignin.hasPlayServices().then((hasPlayService) => {
        if (hasPlayService) {
            GoogleSignin.signIn().then(async (userInfo) => {
                console.log("userInfo", JSON.stringify(userInfo.user))
                setLoading(true);
                const social_Login_Data = {
                    email: userInfo.user.email,
                    name: userInfo.user.name
                }
                console.log("social_Login_Data : ", social_Login_Data);
                try {
                    const res = await api.post(`/Auth/login-single-signin`, social_Login_Data);
                    console.log("response : ", res.data);
                    if (res.data.ack === 1) {
                        console.log('success');
                        navigation.navigate('DrawerNavigation')
                    } else {
                        setItem('social_Login_Data', JSON.stringify(social_Login_Data))
                        navigation.navigate('VerifyEmail',{msg:res.data.message})
                    }
                    setLoading(false);
                } catch (e) {
                    setLoading(false);
                    alert(e)
                }
            }).catch((e) => {
                setLoading(false);
                console.log("ERROR IS1: " + JSON.stringify(e));
            })
        }
    }).catch((e) => {
        console.log("ERROR IS2: " + JSON.stringify(e));
    })
}`

如果有人遇到此错误并解决了此问题,请提供帮助。

android react-native single-sign-on google-signin
1个回答
0
投票

请按照以下步骤操作:

  1. cd ./android && ./gradlew signingReport
  2. SHA1
    Task :app:signingReport
    Variant: debugAndroidTest
    中的
    Config: debug
  3. 在 Firebase 控制台中的
    Project Settings
    Android app
    下更新它,添加
    SHA1
  4. 下载
    google-services.json
    ,放入
    ./android/app
  5. 转至
    Authentication
    ,然后转至
    Sign-in method
    ,然后按
    Google

enter image description here

  1. 拿起
    Web client ID
    并将其用于您的
    GoogleSignin.configure({ webClientId: ... });
  2. 这个
    Web client ID
    应与
    https://console.developers.google.com/apis/credentials?project=<your_project_id>
    ->
    Credentials
    ->
    OAuth 2 Client ID
    ->
    Web Client
  3. 中列出的相同

添加支持电子邮件 > 选择您的项目并打开设置选项卡。

enter image description here

参考链接

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