Auth0 Home Blog Docs

Obtaining access token in dockerized E2E tests

I am developing a mock Auth0 server for when running my dockerized E2E tests as suggested by this article (https://auth0.com/docs/support/testing). The article doesn’t state how to obtain access tokens nor the responses when testing and was wondering how I would be able to?

My application uses the auth0 SPA SDK and I intend on having the requests be sent to my mock Auth0 server in E2E tests. I was planning to send the same response when actually logging in and provide a long lived access token. My only issue is that the longest token I can create is 30 days and unsure what the Auth0 SPA library expects for the rest of the response.

Any help would be appreciated!

1 Like

Hi Andrew.
Not sure how much your test suite will let you mock things, but auth0-spa-js is based on interactive flows: it expects a user to follow all the necessary interactive steps (which could be login, mfa and/or consent) before returning a token. Also, when the SDK makes a token request it generates a random state and nonce values that are expected to be returned in the authentication response, so you’ll need to take that into account as well.