Google App script: Clasp login has stopped working - google-apps-script

I've been using CLASP for the development of Google App Script. Clasp login command is no longer working after Clasp logout.
Steps
Execute Clasp login in VS Code Terminal. It redirects to the Google OAuth page.
Entered credentials and accepted the required permissions for Clasp in the browser
After successful authentication, it redirects to some localhost:port and then it gets stuck with this error
I've also tried using clasp login --no-localhost, but it gave different error:

The problem is that your browser is forcing https:// on your localhost. The way clasp login works is that it creates a temporary local server to receive the authorization code from Google in the OAuth flow. This server won't have an SSL certificate so forcing an https connection will return that error. Your potential solutions are:
Try to just change the start of the URL from https:// to http://, though if it's not working already it probably means that something is forcing it.
Create your own localhost cert. Though this is probably overkill, especially if you want it only to install Clasp.
Temporarily disable any browser extensions or settings that force SSL. Or try a different browser.
You seem to be on Edge, you can go to edge://net-internals/#hsts (or chrome://net-internals/#hsts on Chrome) then add localhost under "Delete domain security policies" and click "Delete".
If this is a corporate device check for any antivirus or policies that would force SSL everywhere and see if you can add localhost as an exception.
If you're completely restricted, you can authorize on another computer that doesn't force SSL on you and just copy the .clasprc.json file from the other %USERPROFILE% folder to your current one. The credentials will be associated with the Google account that you used to sign in.
As for why the -no--localhost flag doesn't work, this is because the Out-Of-Band flow has been deprecated. You can see this in the full description of the error:
This means that the "enter a code" flow is no longer supported and Google has blocked it. It's up to the devs to update the Clasp app to remove the flow or to implement a workaround. You can try to report it in their Github page. As far as I can tell there's not much that can be done about this setting and you most likely will need to go with the localhost method.

Related

How to fix less secure app access problem in Gmail ...?

Google is getting rid of less secure app access feature. I'm using smtp email service for my website's contact page. But after 30 May, 2022 this service will not work probably.
Is there any other way to give third party less secure app access to my Gmail account ..?
Can an app password solve this problem ..? I have doubts that setting app password will not give access either as google said this may not work for less secure app.
So is there any way to fix this so that the smtp email service works as it should ...?
TLDR:
I had a similar problem, I set up an App Password, and my email-sending piece of code is working fine again.
This video shows how to set up App Password.
Google's formal instructions for setting up an App Password.
Caveats:
Initially, Gmail had automatically turned off my less secure apps setting because I hadn't used that test account in several months. I turned it on, but since I saw the message that it'd be disabled by 2022.05.30, I went ahead and set the app password. This means my current setup has both less secure apps AND app password enabled in my Gmail account, though I'm only using the app password for authentication.
My program usually ran from within WSL2 on top of Windows 11. Even after setting up the app password, my code was returning a gaierror: [Errno -3] Temporary failure in name resolution error when running from within WSL2. I then tried running it straight from Windows 11 and it worked just fine. I now need to fix the networking issue causing this, but it doesn't seem to be directly caused by using app password.
I hope this helps.
Note: 2-factor authentication needed to be enabled before proceeding.
Less secure apps (https://myaccount.google.com/u/0/lesssecureapps) options is deprecated.
We can use apppasswords functionality provided by Google using following link.
https://myaccount.google.com/u/0/apppasswords
Use 16 digit code provided by google instead of password and that should serve as authentication token.
It can be done via 2 factor authentication and app password

duck (CyberDuck CLI) with google drive

I'm trying to get the Cyberduck CLI (duck.sh) to work interfacing with a google drive (not "Google Cloud Storage") and I'm having problems getting the oAuth authorization to work. I found this thread but it's out of date - as the newer versions of Cyberduck do absolutely work with Google Drive. Using the regular cyberduck GUI I can browse and operate on my G-drive instance, but I can't quite quack the code (sorry!) for how to make this work using the CLI.
[lwobker:~]$ duck -l googledrive://<user>#gmail.com/
Authenticating as <user>…
OAuth2 Authentication. Paste the authentication code from your web browser.
Authentication Code: <pasted pass here>
Save password (y/n): n
Disconnecting www.googleapis.com…
Login failed. Malformed auth code. Please contact your web hosting service provider for assistance.
I've tried a number of different URLs, including:
#gmail.com
me#gmail.com#www.googleapis.com
and a couple of others.
I also can't seem to figure out where the GUI version of cyberduck stores it's authorized credentials... if I could re-use those that would be fine, doing a one-time setup at the beginning doesn't break my use case.
I'm somewhat familiar with the Google Developers API, and I've created one for use with this project, but I can't seem to figure out how the Google "Client ID" and other credentials map to the Cyberduck tool.
Make sure you paste the auth code obtained from the Google login page opened exactly as is without any line breaks. More information is available in the wiki.

Selenium chrome windows authentication

I am automating a webapplication which uses windows authentication to sign-in.
I am using selenium specflow c# and running my tests on teamcity which uses grid in turn on the build agent.
However each of my row in Examples under scenario outline is testing with a different user.
We are using before scenario hook to create the Remote webdriver instance which is context injected to all the step bindings. However, at this point it is assuming that the user is the logged in user on the hub .
If I am using hub/grid, I am able to test with only one user login as the website takes the user credentials of the logged in user on the hub.
To work around this, we have used credentials embedded in the url. This happens in the Given step much after the hooks run.
While Chrome stopped the support for url credentials, how do I impersonate the users logging into the browser connected via remoteweb driver.
I have explored using process to create webdriver process and passing the credentials. I am not sure if this is the right way.
Or how do I make Chrome prompt for user credentials and stop auto logging as the hub user.
Because of this we are unable to upgrade the Chrome version.
I have explored so much but did not find a conclusive solution.
Regards,
Vijaya

How to avoid the "Your connection is not private" screen when developing an HTTP2 site locally?

When I'm developing using Node's http2 library (which only supports HTTPS, not HTTP), when I open localhost in Chrome, I get a warning screen:
Your connection is not private
Attackers might be trying to steal your information from localhost (for example, passwords, messages or credit cards). Learn more
NET::ERR_CERT_AUTHORITY_INVALID
You have to click "Advanced" then "Proceed to localhost (unsafe)". It gets annoying having to do this during development.
I generated a cert and key for localhost use according to the instructions for Node's http2 module. Is there any way to generate them in such a way that Chrome would actually accept them for localhost? Or is there another easy way to get rid of this warning?
(I'm aware of the option of launching Chrome with --ignore-certificate-errors but I'd prefer not to do this for all websites.)
Try the following:
In Chrome, put in chrome://flags/#allow-insecure-localhost in the address bar.
Enable the option that says "Allow invalid certificates for resources loaded from localhost".
Restart Chrome, and it should allow the site.
You can also type thisisunsafe once you put focus on the website
There are two options you can use to get rid of this annoying thing, which are:
Temporarily Disable SSL Warning
You can go to Google Chrome, input chrome://flags in the address bar and press the Enter key to access advanced settings.
In the next step, find the "Allow invalid certificates for resources loaded from localhost" option and enable it. This method is the same as using --ignore-certificate-errors attribute on your Google Chrome shortcut. It disables the SSL warning for all sites.
It's just a temporary solution and I wouldn't suggest to use this frequently.
(I'm aware of the option of launching Chrome with
--ignore-certificate-errors but I'd prefer not to do this for all websites.)
Install SSL On Your Localhost with OpenSSL
You can install SSL on your localhost with OpenSSL. By using this method, your localhost can run HTTPS without any issue at all. The tutorial is quite long with detailed instructions, you can read it at here.
Source: Fix Your Connection Is Not Private Error In Your Browser - ByteBiteBit.com
I tried too many techniques but nothing works at last i find it while i was learning Webapi.
i was unable to visit to any side beacuse of showing the Error "Your Connection is not Private"......
THE REASON IS You have to enable SSL on your Browser and how you can do it let me share the link..
Just follow the steps
https://www.youtube.com/watch?v=4hb6iD3nP6g&list=PL6n9fhu94yhW7yoUOGNOfHurUE6bpOO2b&index=16
chrome://flags/#allow-insecure-localhost in the address bar.
set it to Enabled
relaunch chrome
result

Chrome & Firefox keep asking for authentication when going to localhost

I'm having a problem where Chrome & Firefox have both started bringing up a popup window saying authentication required when going to localhost (401 page).
If I am on the network I can put in my usual network username/password and it works fine, but if I'm offline (the very reason I'm using localhost) that authentication fails and I get sent to a 403 page.
This does not happen in IE and was not happening a few days ago, my network settings are set to ignore Proxy on localhost and auto detect settings is switched off.
Any ideas?
Problem is the permission of your site directory. If you put the folder under your home (~), then this problem will probably occurs. Try to give your home folder a wider permission. Especially read permission for Others.
sure, if you browse the localhost pure directory you need apache / server authentication
Check your server authentication credentials (user and pass) and this is normal!
while if you browse localhost/mysite you will need not an auth ;)
also be sure your localhost/myproject folder has 755 chmod permissions
finally check if in your localhost/myapp/ there is a .htpasswd file and post it here
I also encountered a similar problem and reinstalling chrome to older version, changing proxy setting didn't help.
I have started using other browsers, however i use the below workaround in case I need to work in chrome.
1.) Click on login without inserting any username and password .
2.) Click on (X) to close the window.
The window would disappear. However, it will reappear if you open any other site or window.