Missing `client_secret` when running offline tests using firebase-functions-test - firebase

I am using firebase-functions-test to unit test my cloud functions. The test is configured to run an offline test, but still, when accessing the test firestore, I get an authentication error: Failed to parse refresh token file: Error: Refresh token must contain a "client_secret" property.. What can cause this?

After digging in the code of firebase-functions-test and firebase-admin, when initializing firebase-functions-test for offline mode, it still uses the gcloud application default credentials. If you have ever installed and used gcloud, this lives in ~/.config/gcloud/application_default_credentials.json.
I had a setup from an old project on GCP that was logged in as a service account instead of an authenticated user, hence I had the default credentials setup, but it did not contain the client_secret required by firebase-admin. I simply logged for application default with gcloud auth application-default login. This solves the issue.
Still a bit baffled by the fact that the offline mode requires authentication. I haven't tested with an invalid, yet correctly formatted application default credentials.

Related

Electron App: How to authorize domain on Firebase

In my electron app, I have integrated the firebase google sign-in authentication method. This method is working properly in the local environment. But after packaging the application (for Linux environment), I am getting an error 'Error while login into Gmail account FirebaseError: Firebase: Error (auth/unauthorized-domain)'. When I tried to find the cause of this error, I found that we have to add the respective domain to the authorization tab but the firebase app domain is already added in settings. As you can see in the screenshot
What else do I need to add here in the domain setting?

Running Firebase web SDK under phantomjs fails to authenticate valid tokens (auth/network-request-failed)

I am trying to use phantomJS to create a pdf of a authenticated part of a Firebase web app.
The set up is as follows
A cloudFunction is triggered when firestore is updated.
The cloudFunction creates a custom token with admin.auth().createCustomToken with the relevant claims.
A url to the hosted firebaseapp app is created, with the token as a query param.
The URL is given to phantomjs to create a pdf of the page.
When the firebase webapp boots, it grabs the token, and uses firebase.auth().signInWithCustomToken
On success it renders the page.
The hosted page works fine, and I can grab the token that the cloudFunction creates, add it to the URL and test it all in chrome with no issue.
However, when running this under phantomJS, the call to admin.auth().createCustomToken fails with
auth/network-request-failed .
A network error (such as timeout, interrupted connection or unreachable host) has occurred.
I have tried the following
Setting '--ignore-ssl-errors=yes', '--ssl-protocol=tlsv1', '--web-security=false' on PhantomJS
Setting Access-Control-Allow-Origin * on the hosting firebase.json rules
Setting a Content-Security-Policy for all the google apis on the hosting firebase.json rules
Does anyone know what would be blocking the google api within phantom?
Could it be the User agent?

Firebase custom token expiration in JavaScript

I have implemented Firebase custom authentication using the firebase-admin library in Python on my server.
The first time I use the token, it works fine and I'm able to authenticate.
But if I restart my node.js application a few minutes later, I get the error:
The custom token format is incorrect. Please check the documentation.
Which I believe means that it has expired, even though I never logged out.
This does not seem to be working:
Once you've called authWithCustomToken successfully, you stay logged in forever (until you sign out explicitly) so you should be able to get devices to have a long-lived authentication session without minting long-lived custom tokens.
How do I explicitly save the authentication between application restarts? Or do I have to mint a new custom token on every restart?
Custom tokens are only valid for an hour. However, I'd suspect your caught error code to be something different. I'm personally on a quest to figure out how to best keep these tokens refreshed, but I do wonder if a deployed instance restarting might be an alternate cause of tokens being invalidated.

Firebase: Local Development and testing in AngularFire

I am using Angularfire to make a website. I am trying to integrate oauth based sign in with google for user authentication but when I try to run index.html file and try to login following error is displayed
11:59:28.189 Error: There are no login transports available for the requested method.
Stack trace:
Mg#file:///G:/Project/root/js/firebase.js:142:1267
dh/<#file:///G:/Project/root/js/firebase.js:163:141
1 app.js:31:4
I searched on stackoverflow for this and got this answer , it says that I need to setup a server for this.
Then I looked at firebase docs and they said
For security reasons, if you're using a web-based OAuth flow
(Facebook, Twitter, Github, or Google), only domains that you
whitelist are allowed to initiate authentication for your app. This
does not apply to Email & Password, Anonymous, or Custom
authentication methods. All Firebase applications have localhost and
127.0.0.1 enabled by default for local development and testing.
The authentication works fine after I host it on firebase but deploying takes a lot of time and also sometimes even I don't have access to internet.
So please suggest me easiest manner so I can run my app on localhost.
An easy way to locally run a Firebase (or any other) web site is to use the Firebase tools and then run
firebase serve
See this blog post introducing the local server.

iam installing swift using below link and i get this error Unauthorized

I am using a tutorial: http://swift.openstack.org/development_saio.html
I'm currently trying to create a swift environment for some test, but got the following error when getting an X-Storage-Url and X-Auth-Token using test command.
UnauthorizedThis server could not verify that you are authorized to access the document you requested.
I am new for openstack, Ples help me..
Try Installing memcache in the server.
In Openstack swift Auth tokens are stored in memcache. So if memcache is not installed auth tokens are not stored which results in failure of authorization.

Resources