`gcloud docker` command refreshing access token on each invocation - gcloud

macOS
Google Cloud SDK 183.0.0
beta 2017.09.15
bq 2.0.27
core 2017.12.08
gcloud
gsutil 4.28
kubectl
I have tried revoking the login and logging in again but every command of gcloud docker refreshes the access token so it hangs about 30 seconds before actually executing a command.
$ gcloud --verbosity=debug docker -- --help
DEBUG: Running [gcloud.docker] with arguments: [--verbosity: "debug"]
INFO: Refreshing access_token
$ gcloud --verbosity=debug docker -- --help
DEBUG: Running [gcloud.docker] with arguments: [--verbosity: "debug"]
INFO: Refreshing access_token
Any ideas what could be causing this?
Login Debug Log
$ gcloud --verbosity=debug auth login
DEBUG: Running [gcloud.auth.login] with arguments: [--verbosity: "debug"]
Your browser has been opened to visit:
https://accounts.google.com/o/oauth2/auth?redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&prompt=select_account&response_type=code&client_id=32555940559.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&access_type=offline
INFO: Successfully retrieved access token
WARNING: `gcloud auth login` no longer writes application default credentials.
If you need to use ADC, see:
gcloud auth application-default --help
You are now logged in as [xxx].
Your current project is [xxx]. You can change this setting by running:
$ gcloud config set project PROJECT_ID
INFO: Display format "none".

Related

cloud_sql_proxy uses unspecified credential file instead of gcloud auth login

My computer rebooted and for some reasons I ignore, cloud_sql_proxy tries to use a credential file instead of my gcloud auth login:
cloud_sql_proxy --instances=instance:region:orcadb=tcp:54321
2022/09/06 12:43:07 Rlimits for file descriptors set to {Current = 8500, Max =
9223372036854775807}
2022/09/06 12:43:07 using credential file for authentication; email=example#example.iam.gserviceaccount.com
2022/09/06 12:43:08 errors parsing config:
googleapi: Error 403: The client is not authorized to make this request., notAuthorized
I checked that my gcloud login is correct by using gcloud auth login, and then checking using gcloud config list account.
I also tried adding the flag --enable_iam_login to the command.
My permissions are already set to owner.
How can I use cloud_sql_proxy without the credential file? Thanks! :)
If no credential file is pointed for cloud_sql_proxy then it takes the file path from the GOOGLE_APPLICATION_CREDENTIALS env. var first.
You have to check if this env var has a value
echo %GOOGLE_APPLICATION_CREDENTIALS%
If yes then clean it up
set GOOGLE_APPLICATION_CREDENTIALS=
Now the cloud_sql_proxy should take the current glcoud account

How to authenticate to GCP for command line uploads

I have created a service account and I can authenticate with a
gcloud auth activate-service-account --key-file <json file>
and I have successfully executed the gsutil rsync command to upload files. The issue is that the gcloud auth command appears to terminate the batch file and the following gsutil rsync commands do not execute. How should the batch file be setup to allow the authentication followed by the rsync commands and then a final auth revoke?

IBM Bluemix registry push authentication error

When pushing to the Bluemix registry, I get the following error:
47c2386f248c: Waiting
2be95f0d8a0c: Waiting
2df9b8def18a: Waiting
unauthorized: authentication required
I've got the cs and cr plugins both installed, an have verified Bx is being added to more auths file. Have tried both using OSX keychain as credstore and without.
When I pull the IBMLiberty example from the BX registry, or build an image with Liberty as the base, it does pull without issue.
I'm running:
docker build . -t registry.ng.bluemix.net/my_space/ibm
docker push registry.ng.bluemix.net/my_space/ibm
Have also tried manually exporting BLUEMIX_TRACE=true and re-running the login and init commands.
Ensure you have logged into the Bluemix Container repository before doing docker push:
$ docker pull registry.ng.bluemix.net/myspace/myimage
Using default tag: latest
Please login prior to pull:
Username (bearer): XXXX
Password:
Error response from daemon: unauthorized: authentication required
$ bx cr login
Logging in to 'registry.ng.bluemix.net'...
Logged in to 'registry.ng.bluemix.net'.
$ docker pull registry.ng.bluemix.net/myspace/myimage:4
4: Pulling from myspace/myimage
7b6bb4652a1b: Downloading [===> ] 5.272MB/70.48MB
See:
$ bx cr login --help
NAME:
login - Log the local Docker client in to IBM Bluemix Container Registry.
USAGE:
bx cr login
It's not clear if you own the namespace my_space can you run bx cr namespaces to see what namespaces you can push to? If need be you can add one with bx cr namespace-add <something unique to you>.

gcloud app deploy, flag to automate prompting?

Is it possible to do silent deployment when using gcloud app deploy
When I run the command gcloud app deploy ./deployment/app.yaml --version v1 its always prompting for
Do you want to continue (Y/n)? Y
how to automate this?
is there any flag that we can pass in to mute this?
You're looking for the --quiet flag, available across all gcloud commands:
$ gcloud --help
--quiet, -q
Disable all interactive prompts when running gcloud commands. If input
is required, defaults will be used, or an error will be raised.
$ gcloud app deploy --quiet
Or also:
$ gcloud app deploy -q

Unable to login to Bluemix via CLI

I am unable to login to my Bluemix account using CLI.
Here are the steps that I followed:
Connected to Bluemix from CLI
E:\myStuff\Coding\Node.js\CloudantDB-NodeApp>bluemix api https://api.ng.bluemix.net
Invoke 'cf api https://api.ng.bluemix.net'...
Setting api endpoint to https://api.ng.bluemix.net...
OK
API endpoint: https://api.ng.bluemix.net (API version: 2.44.0)
Not logged in. Use 'bluemix login' to log in.
Login to Bluemix
Here is the error that I am getting -
E:\myStuff\Coding\Node.js\CloudantDB-NodeApp>bluemix login -u arindam.chattopadhya#wipro.com -o BAS-CES-IBM INTEGRATION -s DEV
Invoke 'cf login -u arindam.chattopadhya#wipro.com -o BAS-CES-IBM INTEGRATION -s DEV'...
API endpoint: https://api.ng.bluemix.net
Password>
Authenticating...
OK
API endpoint: https://api.ng.bluemix.net (API version: 2.44.0)
User: arindam.chattopadhya#wipro.com
No org or space targeted, use 'cf target -o ORG -s SPACE'
FAILED
Error finding org BAS-CES-IBM
Organization BAS-CES-IBM not found
The following command works -
bluemix login -u arindam.chattopadhya#wipro.com -o 'BAS-CES-IBM INTEGRATION' -s DEV