SDK Version: 44.0.2
Platforms(Android/iOS/web/all): all
Hello everyone I have trouble using google authentification with firebase and expo go.
I applied this code so that I can make google authentification work:
import * as React from 'react'
import * as WebBrowser from 'expo-web-browser'
import { ResponseType } from 'expo-auth-session'
import * as Google from 'expo-auth-session/providers/google'
import { initializeApp } from 'firebase/app'
import {
getAuth,
GoogleAuthProvider,
signInWithCredential,
} from 'firebase/auth'
import { Button } from 'react-native'
// Initialize Firebase
initializeApp({
})
WebBrowser.maybeCompleteAuthSession()
export default function App() {
const [request, response, promptAsync] = Google.useIdTokenAuthRequest({
clientId:
'myclicentid.apps.googleusercontent.com',
})
React.useEffect(() => {
if (response?.type === 'success') {
const { id_token } = response.params
const auth = getAuth()
const provider = new GoogleAuthProvider()
const credential = provider.credential(id_token)
signInWithCredential(auth, credential)
}
}, [response])
return (
<Button
disabled={!request}
title="Login"
onPress={() => {
promptAsync()
}}
/>
)
}
But I keep having the following error:
TypeError: provider.credential is not a function. (In 'provider.credential(id_token)', 'provider.credential' is undefined)
What did I do wrong? Can someone help?