Search code examples
node.jsgoogle-cloud-platformgoogle-bigqueryfirebase-authenticationcredentials

Using firebase auth to authenticate google cloud bigquery library - NodeJS


I'm trying to create an app where a user can perform queries on bigquery tables. However the NodeJS BigQuery library requires authentication using a credentials object.

How can I authenticate with bigquery using the same user that's logged in with firebase.auth()?

const {BigQuery} = require('@google-cloud/bigquery')
const firebase = require('firebase')

const app = firebase.initializeApp(..);

await app.auth().signInWithPopup(..)

const bigQuery = new BigQuery({credentials: ???})

Solution

  • There is no way to use Firebase Authentication's to then access Google Cloud's other products, such as BigQuery. BigQuery requires an OAuth2 token, while Firebase uses JWTs. There is no way to convert the latter to the former.

    If your users are signing in to Firebase with a social provider, they may be able to use the OAuth2 token from that provider to access BigQuery. But that is unrelated to their Firebase Authentication session in that case.