Authenticating via Third Party Providers with Cypress Social Login Plugin

Cypress Social Login Plugin is used to facilitate the third-party logins for services such as GitHub, Facebook etc.

It does so by delegating the login process to a puppeteer flow that performs the login and returns the cookies for the application under test, so they can be set by the calling Cypress flow for the duration of the test.

Lets look at how we can use this plugin with an example.

Plugin Reference :- https://github.com/lirantal/cypress-social-logins

  1. Get the Plugin Installed for your cypress project

Installing the plugin would take some time as it needs to install chromium browser and puppeter inside your project.

2. Import the cypress-social-logins plugin definition for the specific social network login you are interested of, and declare a task that performs the login. This can be done by declaring the task as below inside your cypress/plugins/index.js file

3. Add a custom command to call the declared task with a set of options for the social login flow interaction. Set the cookies for the test flow with the help of Cypress.Cookies.defaults. Sample command for authenticating via Google is shown below. This command should be added in your Cypress/Support/Commands.js file.

4. Now you can implement your test spec file with a describe function to call for the custom command defined in step 3.

Some of the important parameters that you need to be aware of related to the above implementation are listed below.

Support of the Plugin with Third Party Authenticators

GoogleSocialLogin > Not Supported as per Googles new policy updates. Reference [2] [3]

GitHubSocialLogin > Supported

MicrosoftSocialLogin> Supported

AmazonSocialLogin >Supported

FacebookSocialLogin>Supported

Major Drawbacks of the Plugin

This plugin doesn’t work well in a Continuous Integration (CI) environment, due to the anti-fraud detection mechanisms followed by the likes of Google, GitHub etc. If you attempt to login from a CI machine which has different IPs, geolocation and other fingerprint identification which the account you use isn’t normally attempting a login from, then this will trigger Multi Factor Authentication, CAPTCHA, or other means of confirming the identity. When those extra steps are needed, this plugin doesn’t work well around them.

References

[1]. https://github.com/lirantal/cypress-social-logins

[2]. https://github.com/lirantal/cypress-social-logins/issues/71#issuecomment-839047895

[3]. https://github.com/lirantal/cypress-social-logins/issues/99

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Shanika Wickramasinghe

Senior Software Engineer and Freelance Technical Writer. I write about any Computer Science related topic. https://www.linkedin.com/in/shanikawickramasinghe