https://cypress.io logo
MFA with Cypress
# i-need-help
f
is there a way we can automate MFA with cypress js.
p
What kind of MFA (microsoft?) Any code of your implementation or specifics of how you want to use it ?
f
Its google MFA and not i did not do any implementation
c
We ended up having to write a script with puppeteer to do our Microsoft oauth flow and then we save the session storage to extract the correct JWTs . It's not pretty but we couldn't get cross origin testing to work in Cypress 12.x
For MS? The flow is simple enough (if you use puppeteer)
s
@colossal-oxygen-29599 I have a hard time using puppeteer with cypress 12. We also want it for ms oauth login flow. It says not able to launch browser(I am using Mac M1) btw
c
Not one I can publically release but I'll give you the general recipe: 1. In a separate script, drive puppeteer through your auth flow and then extract your session storage 2. Save that storage to cypress.env.json 3. Run Cypress and load the saved season storage into your window session
s
Cool, now I'm getting this error: AADSTS9002327: Tokens issued for the 'Single-Page Application' client-type may only be redeemed via cross-origin requests.
4 Views