expo firebase google signin给出:第一个参数“ idToken”必须为有效字符串或有效对象,或者为null

时间:2018-12-22 16:12:18

标签: reactjs firebase react-native firebase-authentication expo

https://docs.expo.io/versions/latest/sdk/google

我通过google进行身份验证时会遵循官方网站上的集成指南,这会给我带来这样的错误

  

凭据失败:第一个参数“ idToken”必须为有效字符串或有效对象,或者为空

_handleGoogleAuth = async () =>{
    console.log(ENV.androidClientId)
    const { type, token } = await Google.logInAsync({ 
        androidClientId: ENV.androidClientId,
        iosClientId:ENV.iosClientId,
        behavior: Platform.OS === 'ios' ? 'web' : 'system'
    })
    console.log(type+'type')

    if (type == 'success') {

      const credential = firebase.auth.GoogleAuthProvider.credential(token)
      console.log(credential.idToken)

      firebase.auth().signInWithCredential(credential).catch((error) => {
        console.log(error)
      })
    }

}

1 个答案:

答案 0 :(得分:0)

expo-google-signin库存在一个已知错误,其中idToken有时是accessToken作为未定义返回。

它也可能扩展到Google博览会。