2

I have a Firebase cloud function that I would like to make a Callable function so that I can call it from my web clients with authentication built in. But I would also like to call it from my own back end code using the Admin SDK (specifically from Java) if that matters.

I see that the protocol is documented, but I am a little unclear how to authenticate it from the Admin SDK. I know you can create a token, but this doesn't seem to be the correct Bearer token that the Callable function expects. How can I generate one of those? Or is there a better way to call a Callable function securely from the Admin SDK?

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Dan
  • 10,990
  • 7
  • 51
  • 80

1 Answers1

10

Since backend code doesn't run with end-user credentials (there is no user signed in to your backend), you won't have access to an ID token that's required to send with the request. There is really no good way to artificially manufacture this.

What you can do instead is create a separate HTTP function to call from your java code that doesn't require a user auth token. If you want, you can require it to use some other form of authentication that doesn't use end-user credentials. You can also share the implementation between both the callable and the HTTP trigger by providing a shared function they can both invoke that does the real work.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441