clasp icon indicating copy to clipboard operation
clasp copied to clipboard

Can't run "clasp login" command

Open taiseiyo opened this issue 3 years ago • 16 comments

I want to do clasp login and use clasp, but I can't login.

Expected Behavior

I want the login process to work correctly. I want to display the Google authentication popup correctly.

Actual Behavior

The screen looks like the image below and I can't proceed. image

Steps to Reproduce the Problem

  1. install clasp → npm install -g @google/clasp
  2. run "clasp login --no-localhost"
  3. copy URL and paste URL to Google Chrome

Specifications

  • Node version (node -v): v18.12.1
  • Version (clasp -v): 2.4.2
  • OS (Mac/Linux/Windows): Linux (debian)

taiseiyo avatar Jan 05 '23 04:01 taiseiyo

+1 also having this issue

H3rby7 avatar Jan 12 '23 15:01 H3rby7

+1 I have also faced issue after the latest version upgrade

rnsharma10 avatar Jan 20 '23 15:01 rnsharma10

Me too

wip-abramson avatar Jan 24 '23 14:01 wip-abramson

me too. For me even clasp login not working. Is there any other way to login? please check https://stackoverflow.com/questions/75347604/google-app-script-clasp-login-has-stopped-working

jayakrishnankg avatar Feb 05 '23 05:02 jayakrishnankg

+1

hongyin163 avatar Mar 03 '23 02:03 hongyin163

The --no-localhost option will no longer work due to Google disabling Out-Of-Band OAuth - the "copy and paste" method is dead.

phw198 avatar Mar 12 '23 17:03 phw198

I had this issue with wanting to run things in docker and ended up hacking myself a little workaround -> https://github.com/H3rby7/clasp-docker

H3rby7 avatar Mar 12 '23 19:03 H3rby7

Since it's just the --no-localhost option that's blocked, I ran clasp login locally on my mac terminal, and then copied the contents of my local "~/.clasprc.json" into the other remote environment I needed auth in.

dandelion12345 avatar Apr 19 '23 20:04 dandelion12345

Since it's just the --no-localhost option that's blocked, I ran clasp login locally on my mac terminal, and then copied the contents of my local "~/.clasprc.json" into the other remote environment I needed auth in.

This kind of workaround beats the entire purpose of running virtual development environments. Clasp should do better than that. It's an important tool in the AppsScript developer's toolbox. What are they going to do when Google's IDX is officially shipped and developers try to develop AppsScript from there?

tailorvj avatar Aug 30 '23 19:08 tailorvj

I found a working clasp login solution for containers on StackOverflow:

Original post from StackOverlow by Paul: When using cloud SaaS such as gitpod, the disablement of out of band (OOB) OAuth also causes problems. The workaround here is to use clasp login and copy the URL in the localhost page that fails at the end. Start a new bash terminal on the cloud service and then run curl '<paste in URL>' – Paul Mar

I tested it on Gitpod and it works like a charm. Here's what I did to login from within the Gitpod cotainerized environment:

  • $ clasp login
  • Opened the URL
  • Logged in
  • Copied the final URL from the browser
  • Back in Gitpod opened a new terminal
  • $ curl
  • Login successful

I hope this helps someone

Kind regards, Tailor VJ

tailorvj avatar Aug 30 '23 20:08 tailorvj

@tailorvj I tried that, and after running curl ... inside the container I get this output:

Logged in! You may close this page

And in the other terminal I had issued clasp login --creds creds.json from I see this:

Authorization successful.

Local credentials saved to: /var/www/html/.clasprc.json.
*Be sure to never commit this file!* It's basically a password.
No access, refresh token, API key or refresh handler callback is set.

But afterwards clasp login --status comes back with:

You are not logged in.

It seems that Clasp is completely broken. Really sad state of affairs.

lpeabody avatar Jan 03 '24 18:01 lpeabody

@tailorvj I tried that, and after running curl ... inside the container I get this output:

Logged in! You may close this page

And in the other terminal I had issued clasp login --creds creds.json from I see this:

Authorization successful.

Local credentials saved to: /var/www/html/.clasprc.json.
*Be sure to never commit this file!* It's basically a password.
No access, refresh token, API key or refresh handler callback is set.

But afterwards clasp login --status comes back with:

You are not logged in.

It seems that Clasp is completely broken. Really sad state of affairs.

I have just tested clasp login on Gitpod with the following repo, and it seems to be working just fine by using the curl hack on a second terminal. https://github.com/tailorvj/hello-clasp

Try to fork it, deploy it to gitpod.io (Instructions in the README), and let me know whether it's worked for you.

Here is a video where I demo from Google's C2C online meetup where I demo this login technique: https://www.youtube.com/watch?v=RaMt5yZdzqI

I hope this helps. Kind regards, Tailor

tailorvj avatar Jan 04 '24 06:01 tailorvj

@tailorvj something I had to do was move the .clasprc.json file that gets generated to the home directory of the user in the Docker container. Once I did that this worked fine. So, it would appear that this specific file needs to live in the home directory.

lpeabody avatar Jan 04 '24 13:01 lpeabody

@tailorvj something I had to do was move the .clasprc.json file that gets generated to the home directory of the user in the Docker container. Once I did that this worked fine. So, it would appear that this specific file needs to live in the home directory.

I think that is correct. I found this file on my local system as well, at the same location. I guess on Gitpod this is enabled by default. I'm not a huge ecpert on Docker though, so can't tell for sure. Glad you managed to get it working

Cheers, Tailor

tailorvj avatar Jan 04 '24 15:01 tailorvj

I found a working clasp login solution for containers on StackOverflow:

Original post from StackOverlow by Paul: When using cloud SaaS such as gitpod, the disablement of out of band (OOB) OAuth also causes problems. The workaround here is to use clasp login and copy the URL in the localhost page that fails at the end. Start a new bash terminal on the cloud service and then run curl '' – Paul Mar

I tested it on Gitpod and it works like a charm. Here's what I did to login from within the Gitpod cotainerized environment:

  • $ clasp login
  • Opened the URL
  • Logged in
  • Copied the final URL from the browser
  • Back in Gitpod opened a new terminal
  • $ curl
  • Login successful

I hope this helps someone

Kind regards, Tailor VJ

This solution worked for me.

leetutoring avatar Mar 29 '24 18:03 leetutoring

I'm having kinda the same problem, but I'm not able to get it to work with the above solution. I'm trying to integrate GAS with Github Actions.

I logged manually in my machine so I could copy the credentials, following this tutorial to get everything running. But even with the credentials, when trying clasp login --no-localhost --creds creds.json, it still asks me to enter a URL in the browser.

How can I get it to work without manually accessing the URL? Also, if I do access the URL, it returns the error shown in the first post.

Any help is much appreciated.

jt-clavis avatar Jul 26 '24 19:07 jt-clavis