Google "Open In Cloud Shell" broken? - google-cloud-shell

Did Google just break its own "Open in Cloud Shell" feature?
I'm getting this error when trying to use a cloud shell link that specifies a git repo to clone from.
fatal: could not read Username for 'https://github.com': terminal prompts disabled
I've tried on a virgin Google account, so pretty sure it's something to do with the default Cloud Shell VM setup and not something I did on the machine. It literally stopped working from one moment to the next.

Github is shutting down password authentication in favor of token-based authentication. To avoid confusion, Open in Cloud Shell will now fail instead of prompting for username/password. To continue to use Open in Cloud Shell with repositories that require authentication, you can either:
Manually cache your git credentials by running a git command prior
to Open in Cloud Shell.
Configure git credential storage so you are not prompted for a
username/password.

Related

Get rid of annoying logs by Firebase function "this may be a production service" & "External network resource requested"

When running a Firebase function, my logs are very noisy mostly because of those 2 messages
Be careful, this may be a production service.
⚠ External network resource requested!
I know I am running a production service, and yes I am requesting an external ressource πŸ˜… can I disable them?
Thanks
Normally using --quiet would silence this message, however because there are so many emulators, the Firebase team couldn't reach a consensus on whether to allow this to be silenced when used with firebase emulators:start (see firebase-tools Issue #2859).
The official stance on this is to set the logs filter to only show "user" logs using the Emulator Suite UI's Logs Viewer and let the regular log feed log everything.

There was an error granting Firebase Service Agent access to your secret

I am facing an error while installing an Algolia extension into my firebase project.
Error-
When I click on the "Create secret" button, the error below is visible
Only admin can add Key. Check your project permission
When installing the extension it will ask you to enable the secrets API, what this does is enables the Secrets Manager API from google cloud (what firebase is built on top of). You can manually check this is enabled with the below URL, and if its not - enable it.
https://console.cloud.google.com/apis/api/secretmanager.googleapis.com/overview?project=YOUR_PROJECT_ID
As with all google cloud API's, when you enable them it takes a few minutes for the changes to propagate. Try again in ten minutes, and you will find your error is resolved, you're able to create the secret, and you can install the extension.

Firebase CLI is not authenticating because Google account is not retaining authorization

I just downloaded the Firebase CLI (through firebase-tools NPM module) and I'm trying to firebase login. Each time I'm redirected to my browser where I give the Firebase CLI app permissions to my account and I keep getting a screen saying "Firebase CLI Login Failed":
I've tried running firebase login --no-localhost and that also doesn't seem to work.
When I look at my Google Account OAuth authorizations (https://myaccount.google.com/permissions), Firebase is not listed. It's as if Google isn't saving my option to allow the Firebase CLI app when I click "Allow" on this screen.
I've tried this on two different Internet connections with two different Google accounts (one Gmail and on G Suite) and the results are the same. Is there anything I'm missing?
After some more troubleshooting and research I found that Firebase CLI will not authenticate or deploy properly if your computer is behind a proxy. This is a known issue on GitHub. I had a program installed on my computer that monitors all my Internet traffic and it does so using a proxy. Once I uninstalled that program, Firebase CLI was able to authenticate and deploy without an issue.

Firebase tools login from command line

I'm using Codeship to deploy a firebase app.
In order to do so, I first need to login using the firebase login command. Problem is, I need to login in the browser and then return to the command line and perform the deployment.
Is there an automated way to supply credentials to Firebase?
Cheers
firebase login --no-localhost is what worked for me. You get the Authorisation code from browser which you need to paste into your terminal window.
The accepted answer is correct for the old version of firebase-tools, however this has been deprecated as of version 3. The new command to get the token is:
firebase login:ci
You should save this in some kind of environment variable, ideally, FIREBASE_TOKEN.
Then, with any command you intend to run via ci (i.e. deploy), you can run:
firebase [command] --token [FIREBASE_TOKEN]
See wvm2008's answer for a more up to date version
One option would be to mint a token for the build server and pass it into the CLI with:
firebase --token <token>
You can also get a token from a system where you interactively logged in with:
firebase login:ci
See this page for more options.
Answer: Environmental Variables.
Specifically, using a machine with a browser and firebase tools installed, run firebase login:ci --no-localhost and paste the resulting key from the firebase CLI tool into an Environmental Variable and name it FIREBASE_TOKEN (not $FIREBASE_TOKEN).
In your deployment, say
npm install -g firebase-tools
firebase deploy
Done. If you care about Why? Read on.
The firebase/firebase-tools repo README indicates the following regarding Usage with CI Systems.
The Firebase CLI requires a browser to complete authentication, but is
fully compatible with CI and other headless environments.
On a machine with a browser, install the Firebase CLI. Run firebase
login:ci to log in and print out a new access token (the current CLI
session will not be affected).
NOTE: You actually want to type firebase login:ci --no-localhost
Store the output token in a secure but accessible way in your CI
system. There are two ways to use this token when running Firebase
commands:
Store the token as the environment variable FIREBASE_TOKEN and it will
automatically be utilized. Run all commands with the --token <token>
flag in your CI system.
πŸ‘‰ NOTE: You MUST put your token in quotes IIF using the --token flag
πŸ”₯ πŸ‘‰BIGGER NOTE Do NOT prefix your environment variable with $ or you will get a nonsensical error message below!!!
Your CLI authentication needs to be updated to take advantage of new features.
Please run firebase login --reauth
Error: Command requires authentication, please run firebase login
The order of precedence for token loading is flag, environment
variable, active project.
πŸ‘Œ Recommendation is to use Environmental Variable so the secret token is not stored/visible in the logs.

Firebase CLI Authentication through token

I followed the steps described in the official GitHub tutorial for use the Firebase CLI (Command Line) with a CI system (simple OS without browser integrate). I use my PC to login in firebase and get the token (from the browser procedure). I copied the token on the other system and I passed the token in all command but it does not work. I get the message that I need to be authenticate for doing these operations:
firebase login
firebase prefs:token
copy and use the token in other system
firebase list --token sdfgfdsg......
What's the problem?
Using a machine with a browser and firebase tools installed, run firebase login:ci --no-localhost and paste the resulting key from the firebase CLI tool into an Environmental Variable and name it FIREBASE_TOKEN (not $FIREBASE_TOKEN).
In your deployment, say
npm install -g firebase-tools
firebase deploy
Make sure not to run firebase logout on your PC, as doing so will invalidate the token (we're working on making this clearer now, actually).
If not, make sure that you're quoting the token:
firebase list --token '-K.....|.....'
The characters included in the auth token may cause shell errors that prevent the command from completing properly if it's not quoted.
I was facing the same problem with Travis, and the problem was the encryption of the token used by travis, you have to ensure you have correctly escaped the pipe symbol inside the token.
in my case something like
travis encrypt 'FIREBASE_TOKEN=-jksdjksjksdj\|ksdkjsjk'
Hope this helps, because I can ensure you that if you do:
firebase deploy --token '-jksdjksjksdj|ksdkjsjk'
in Travis it just works.
firebase is not recognizing the token in your case for some reason, you need to find that reason
Check this out:
http://docs.travis-ci.com/user/encryption-keys/

Resources