Auth0 throws Callback URL mismatch when accessing Angular SPA deployed on Nginx on EC2

932 views Asked by At

I currently have my Angular app running on Nginx within an EC2. I did this so that I could create a Self-Signed SSL Certificate so that Auth0 would recognize it as a "secure origin".

Now I have my app successfully running at https://my_server_IP, but every time I click Auth0 sign-in, which previously worked when I was running it locally, I get the following message:

Callback URL mismatch.
The provided redirect_uri is not in the list of allowed callback URLs.
Please go to the Application Settings page and make sure you are sending a valid callback url from your application.

I have changed the following lines in in auth_config.json:

{
  "domain": "my-account.us.auth0.com",
  "clientId": "my-client-id",
  "audience": "{API_IDENTIFIER}",
  "apiUri": "http://localhost:3001",
  "appUri": "http://localhost:4200",
  "errorPath": "/error"
}

...to this (after passing index.html to Nginx server deployed on EC2 and enabling SSL certs following this guide):

{
  "domain": "my-account.us.auth0.com",
  "clientId": "my-client-id",
  "audience": "{API_IDENTIFIER}",
  "apiUri": "https://my_server_IP",
  "appUri": "https://my_server_IP",
  "errorPath": "/error"
}

My question is: is it even possible to use Auth0 if this app is running on Nginx on an EC2 instance?

Are there any other steps I need to take besides going to the Application Settings page and making sure that I'm sending a valid callback url from my application? (I'm waiting on a fellow dev to log in and do this, as I'm currently working on the deployment of the frontend which works except for the Auth0).

1

There are 1 answers

0
kodazys On

Resolved! Just had to add the exact URL (https://my_server_IP) to the list of valid callback URI's in Auth0 dashboard.

Additionally, there was no use for the appUri or apiUri fields in auth_config.json. My auth_config.json file still looks like this (no changes except deleting the unused props):

{
  "domain": "my-account.us.auth0.com",
  "clientId": "my-client-id",
  "audience": "{API_IDENTIFIER}",
  "errorPath": "/error"
}