I have created an Oauth flow on github with a FeathersJS backend. When running this on localhost it is all working fine. Currently, I am testing the deployment to AWS on EC2 and on the EC2 instance, I can't get the flow to work. I get the redirect_uri_error.
{
"error": "redirect_uri_mismatch",
"error_description": "The redirect_uri MUST match the registered callback URL for this application.",
"error_uri": "https://developer.github.com/apps/building-integrations/setting-up-and-registering-oauth-apps/troubleshooting-oauth-app-access-token-request-errors/#redirect-uri-mismatch(2)"
}
I think feathers automatically creates the redirect uri from the parameters in the config files. According to the docs that uri looks like this: http(s)://hostname[:port]/auth/<provider>/callback
. I am running the app in production mode with the settings below. What am I doing wrong?
default.json:
{
"host": "localhost",
"port": 3030,
"public": "../public/",
"paginate": {
"default": 10,
"max": 50
},
"mongodb": "my_mongo_connection_string",
"authentication": {
"secret": "my_auth_secret",
"strategies": [
"jwt",
"local"
],
"path": "/authentication",
"service": "users",
"jwt": {
"header": {
"type": "access"
},
"audience": "https://example.com",
"subject": "anonymous",
"issuer": "feathers",
"algorithm": "HS256",
"expiresIn": "1d"
},
"local": {
"entity": "user",
"usernameField": "email",
"passwordField": "password"
},
"github": {
"clientID": "my_client_id",
"clientSecret": "my_client_secret",
"successRedirect": "/"
},
"cookie": {
"enabled": true,
"name": "feathers-jwt",
"httpOnly": false,
"secure": false
}
}
}
production.json
{
"host": "my-ec2-instance.compute.amazonaws.com",
"port": "3030"
}
EDIT: Changed succesRedirect to "/"
Ok, I found the solution to this problem. In production mode, the feathers application still takes the URL from default.json to build the callback URL. Therefore, the production URL should not only be filled in in production.json, but the same URL should be entered in default.json as well.