Auth0 Home Blog Docs

Get token for automated tests

tests
#1

Hi, All!
I will plan automate my API tests.
In tests I use token which generated by Auth0.
For take this token I use login\password for authentication on website and copy token in special info section.
How I can receive this token automatically and paste it in my yml file with test ?

#3

You can enable the Resource Owner Password Grant, which lets applications exchange a user’s credentials directly for a token. You should enable this only for the test application, and the test suite can get a token using this flow.

#4

Is it mean that I must include clientID/secretID of application inside tests ?

#5

That is correct. You should have a client/application created specifically for this purpose, and make sure it’s only available on a test/dev environment.
Another option would be to change the configuration of your backend API in the testing environment to accept tokens signed with an alternative key (not the one from Auth0), and build the tokens yourself from a test helper/mocked token issuer.

#6

Is this something that can bypass MFA? Similar issue here with trying to run automated tests and having MFA enabled.