How to log in to google account using Playwright or Puppeteer? - node.js

Could someone please help me, I need to log in to my google account using Puppeteer or Playwright. Is there a way to do it ?

Most of the cases Google prevents login for headless browsers/bots. You may see some similar message when you try it:
Couldn't sign you in
For your protection, you can't sign in from this device.
Try again later, or sign in from another device.
You need to make sure that you are able to login with your script in "headful" mode by giving the credentials (with page.click and page.type like a real user would) and submitting the form.* If it works headful but you need it to work in headless mode then you can use puppeteer-extra package with puppeteer-extra-plugin-stealth. Examples can be get from puppeteer-extra docs. FYI: pptr-extra uses older puppeteer 2.x as its base, you may loose some functionalities even if it can be used together with the original puppeteer library.
*If there will be a need to handle two-factor authentication that makes the task more complex. You can be sure Google does its best to prevent bots from logging in.
+ You can test your puppeteer Chromium instance if it is detected as headless browser here: https://arh.antoinevastel.com/bots/areyouheadless

Related

How to implement Apple Sign In in Chrome Extension MV3?

I have a Chrome extension built with MV3. It is a companion product to a mobile app that allows users to sign up / sign in with email, Google, and Apple. I have used the Firebase Authentication service to set up email sign up and Chrome Identity API to set up Google Sign in (solutions offered e.g. here & here). However, Apple Sign in (or any other 3rd party auth) seems to be completely broken in MV3 because popup/redirect OAuth operations are not yet supported in MV3. Seems like such a big miss by the Chrome Extension team!
My question
Is there a workaround solution to implement Apple Sign in for Chrome extensions using MV3?
Solutions I've tried thus far
I've spent a week now testing/trying different ideas and this is the closest I've gotten. Quick summary of solutions tested (in case it can help others save time):
Firebase Authentication service for Apple Sign in. It offers two methods that can be used, signInWithPopup and signInWithRedirect. As noted above though, popup/redirect operations aren't supported in MV3, so neither of these worked. I also tried this approach (also seen here) of storing the Firebase Auth files locally in case fetching remote scripts was the main culprit. That however didn't work either because the files still have some dynamic (remote) script imports that are called at compile time (I think) which again is prevented in MV3.
FirebaseUI library. In short, this library depends on the main Firebase library and therefore you get the same issues as the above.
Sign in with Apple JS. This implementation makes a call to fetch the Apple JS script. Again, MV3 doesn't allow for remote scripts, so it fails. As a workaround, same as with the first option above, I copied the Apple JS script and stored it locally in the extension. But it doesn't work in this case either. (I don't recall the exact reason, but the Apple auth object in the file wasn't instantiating or something).
Sign in to Apple manually. The most promising result thus far but I am stuck at how to read/extract the authorization response from Apple. I've outlined that issue here.
The only remaining workaround that I can think of is that I set up an externally hosted site using Sign in with Apple JS (option 3 above). Then when the user clicks the Apple Sign in button in my Chrome extension, I redirect them to that site, they conduct the Apple Sign in, and the auth details are then sent back to the Chrome extension. That however is both a very poor user experience and presumably has many security flaws.
Has anyone successfully implemented Apple Sign in with Chrome extension MV3 or can offer some workable solutions?? Thanks in advance.

SharePoint Application feasibility with JMETER

I have been facing issue with JMeter recently where I needed to understand if JMeter supports SharePoint Application?
I am stuck at the recording of a simple Login-Logout page where ADID Authentication is involved, whenever I try to record in the following manner it gets stuck on the ADID Popup only:
Hit HomePage
ADID Pop-up window (here when I enter valid credentials it just asks for the same thing)
Can anyone guide me if there is something that needs to be done in order to work it with JMeter?
You need to
Figure out what authentication method is being used under the hood, like Basic, NTLM, or Kerberos. Just ask around or inspect request/response headers using your browser developer tools or a 3rd-party sniffer tool like Wireshark
Add HTTP Authorization Manager and properly configure it for the required authentication type, see Windows Authentication with Apache JMeter article for example setup
You can also use an alternative recording solution like JMeter Chrome Extension, but you will still need the HTTP Authorization Manager in order to properly replay the recorded script

Is it possible to run Puppeteer on server-side?

I want to use Puppeteer to automate a particular task. However, for user-friendly purposes, I thought about implementing it within a chrome extension. Browsing the web, I encountered this article https://dev.to/tchan/web-automation-using-puppeteer-inside-a-chrome-extension-318o To be honest, I could not absorb some context from the article since I don't have enough experience about that kind of stuff. According to the article, I had to activate remote debugging for chrome. So I did, yet could not access localhost, thus webSocketDebuggerUrl property, either. Some connection refusal error hit on the browser while trying to access. But the thing about I care is that in the case that it even works, if I had published this extension, one would have to activate his/her remote debugging for chrome, too and that would not be much of user-friendly. In the end, I thought that if it is possible to run Puppeteer on nodejs with your own computer, it should be possible to run it on server-side(nodejs) of a website, too. Thus, you wouldn't need an extension, so the website itself would implement the task I have intended. Sorry for this long story-wise problem, but still I don't have much knowledge of server-side languages. So is it possible to run Puppeteer on server-side? So what would you recommend to do?
Thanks.

Google Login Not Allowed Selenium

I am running a selenium automation test from a Linux terminal only using the command line(No GUI)
I am getting now an error that says
If I run this headless on my local mac it works fine. Has anyone experienced this error before?
UPDATE: As of January 2021, this no longer works.
I know this is quite a late answer, but logging in to Google is still possible (by exploiting a bypass).
By default, Google detects and effectively blocks all logins from Selenium webdriver.
The following link comes from the Google OAuth Playground, ensuring the practicality of the link. It most likely won't expire any time soon.
https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&prompt=consent&response_type=code&client_id=407408718192.apps.googleusercontent.com&scope=email&access_type=offline&flowName=GeneralOAuthFlow
You can use that link (ie. driver.get()) to log into your Google account.
This bypasses the automation checks allows you to log into Google using Selenium. At least for now.
UPDATE: As of January 2021, this no longer works.

How to launch a chrome packaged app using a URL scheme

I have a chrome packaged app that I update form time to time - when I'm creating an update I want to send email to subscribed customers with a link the that extension -that will launch it.
Anyone knows if there is a chrome url scheme i can use?
Currently this is not possible, but there is an API proposal and an implementation being developed for a chrome-app://appid URL schema that would do pretty much what you describe.
Follow the status here
I also want to be able to do this. It seems that one possible solution is to install both an extension and a packaged app, and have the extension register a context menu that then communicates with the app, or something similar.

Resources