Hi, I need to fetch data from firebase. To do that, i need access_token (I dont want to use firebase secret which is deprecated).
How can i generate firebase access token using serviceaccount file which i generated from Firebase?
Thanks,
Prabhat
Solved! Go to Solution.
Hi Prabhat!
Here's a repo of a working API Proxy that shows an example for doing exactly that.
If you have a service account file like this:
{ "type": "service_account", "project_id": "YOUR-PROJECT-NAME", "private_key_id": "bdb91206c515893e1f6815e6b80bff113f92a1a0", "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADAN.......FRPE=\n-----END PRIVATE KEY-----\n", "client_email": "YOUR-PROJECT-NAME@appspot.gserviceaccount.com", "client_id": "10ee87dh4855500679513", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://accounts.google.com/o/oauth2/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/blah-blah-blah@gserviceaccount.com" }
...then you can use this proxy to connect.
Hi Prabhat!
Here's a repo of a working API Proxy that shows an example for doing exactly that.
If you have a service account file like this:
{ "type": "service_account", "project_id": "YOUR-PROJECT-NAME", "private_key_id": "bdb91206c515893e1f6815e6b80bff113f92a1a0", "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADAN.......FRPE=\n-----END PRIVATE KEY-----\n", "client_email": "YOUR-PROJECT-NAME@appspot.gserviceaccount.com", "client_id": "10ee87dh4855500679513", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://accounts.google.com/o/oauth2/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/blah-blah-blah@gserviceaccount.com" }
...then you can use this proxy to connect.
Thanks. Its working with your approach.
However before your solution, i was trying to use gogole-api module as suggested in this for node. it was working perfectly OK on my dev machine however it was failing to load google-api-auth module on apigee.
Hi Prabhat - you said "it was failing to load...on apigee" . What does that mean, exactly? Were you using the node target, based on Trireme? The google-api module is not expected to run there. Many modern modules will not run in Trireme. But they will run in a Hosted Target.
Thanks Dino. Now it makes sense. I was trying with node-target. I was not aware about hosted function feature with apigee. After your comment, i went through hosted function feature and it makes more sense now.
Thanks for your help