# Updating auth0-react login state during cypress test

**URL:** <https://community.auth0.com/t/updating-auth0-react-login-state-during-cypress-test/48308>\
**Category:** Get Help\
**Tags:** api, login, auth0\
**Created:** [August 19, 2020, 12:17pm UTC](https://community.auth0.com/t/updating-auth0-react-login-state-during-cypress-test/48308 "2020-08-19T12:17:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rich8212](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rich8212/32/23296_2.png) [@Rich8212](https://community.auth0.com/u/Rich8212)\
**Post date:** [August 19, 2020, 12:17pm UTC](https://community.auth0.com/t/updating-auth0-react-login-state-during-cypress-test/48308/1 "2020-08-19T12:17:10Z")

</div>

I’m trying to login to auth0 during a cypress test using auth0-react. I’ve followed this guide -

> **[End-to-End Testing with Cypress and Auth0](https://auth0.com/blog/end-to-end-testing-with-cypress-and-auth0/)**
>
> Learn how to programmatically authenticate against Auth0 in your Cypress tests in a manner that adheres to both Cypress and Auth0 best pr...

That guide does not use auth0-react and has a custom state/auth handler which updates once the `{ access_token, expires_in, id_token }` are received.

Is there any simple way to update the auth0-react login state once the tokens are received?

Ideally, I’d be able to use some endpoint to receive the usual code which is given when logging in with the UI. For example, receive code xxx and redirect to:

[http://localhost:3000/dashboard?code=xxx&state=yyy](http://localhost:3000/dashboard?code=xxx&state=yyy)

auth0-react would then update the login state automatically when it parses the URL.

Someone asks the same question in a comment on the post but there isn’t a response:

“I would like to be able to implement a Cypress “login” command that exercises my callback with a `code` (i.e. authorization code) that would typically be acquired via OAuth exchange. Is there an Auth0 API endpoint that allows me to get a `code` that I can then use for my callback e.g. [https://mydomain.com/callback?code=abcd1234?](https://mydomain.com/callback?code=abcd1234?)”

Any ideas?

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [August 19, 2020, 12:28pm UTC](https://community.auth0.com/t/updating-auth0-react-login-state-during-cypress-test/48308/2 "2020-08-19T12:28:38Z")

</div>

A post was merged into an existing topic: [End-to-End Testing with Cypress and Auth0](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082)

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [August 19, 2020, 12:28pm UTC](https://community.auth0.com/t/updating-auth0-react-login-state-during-cypress-test/48308/3 "2020-08-19T12:28:38Z")

</div>


