I have an application that uses NestJS and Angular. I am currently using @auth0/auth0-angular on the frontend to log users in and out. I want to write e2e tests with Supertest using the Authorization Code Flow and if I’m understanding everything correctly, I have to:
1) Authorize the user by sending the user to the authorization URL 2) If all goes well, I should receive an HTTP 302 response which includes an authorization code 3) Exchange this authorization code for tokens by POSTing to the token URL ('https://YOUR_DOMAIN/oauth/token'). 4) If all goes well, I should receive an HTTP 200 response with a payload containing the tokens.
However, since I’m writing tests with Supertest on the backend, I can’t send a user to the authorization url and have the user handle authentication. Is there a way to get around this and get an authorization code so that I can POST to the token url in order to get the tokens?