0

I have a Firebase project in which users have authenticated with Google Sign In method. They also did grant me access to the ...auth/content scope.

Now, I'd like to perform some actions on their behalf in my backend code via Google Cloud Library.

I don't know how to properly initialize google client to make it authorized to perform certain actions.

    import { google } from "googleapis";

    const authUser = await adminApp.auth().getUser(`...`)
    const googleAuth = new google.auth.GoogleAuth({
        // ???? How can I init it with `authUser`?
    })
    // Acquire an auth client, and bind it to all future calls
    const googleClient = await googleAuth.getClient()
    google.options({ auth: googleClient });

Is there any way to use Firebase Auth with Google Cloud node.js lib?

msmialko
  • 1,439
  • 2
  • 20
  • 35
  • Hi there, qq, what actions do you want to perform? I assume you have followed [1] to authenticate using Google Sigin in Firebase. [1] https://firebase.google.com/docs/auth/web/google-signin – Antonio Ramirez Apr 29 '21 at 16:46
  • I want to call the Google API on behalf of the user (Google Content API specifically) but from the backend, without the user having their browser opened. Those users signed in with Google In my app and have me scope permission so it should be possible. But Firebase doesn’t give me any refresh token so I don’t know how to get the valid access token when the user is not in the browser. – msmialko May 01 '21 at 07:09
  • 1
    Does this answer your question? [How to use the Firebase refreshToken to reauthenticate?](https://stackoverflow.com/questions/38233687/how-to-use-the-firebase-refreshtoken-to-reauthenticate) I mean the second answer with 35 upvotes. – Antonio Ramirez May 05 '21 at 17:28
  • Thanks @AntonioRamirez, I think you're right. That post you linked is helpful. – msmialko May 07 '21 at 19:48

0 Answers0