【发布时间】:2017-11-03 16:44:15
【问题描述】:
我在 github 上创建了一个带有 FeathersJS 后端的 Oauth 流。在本地主机上运行它时一切正常。目前,我正在 EC2 和 EC2 实例上测试到 AWS 的部署,我无法让流程正常工作。我得到了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)"
}
我认为羽毛会根据配置文件中的参数自动创建重定向 uri。根据 uri 看起来像这样的文档:http(s)://hostname[:port]/auth/<provider>/callback。我正在使用以下设置在生产模式下运行该应用程序。我究竟做错了什么?
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
}
}
}
生产.json
{
"host": "my-ec2-instance.compute.amazonaws.com",
"port": "3030"
}
编辑:将 succesRedirect 更改为“/”
【问题讨论】:
-
诚然,我以前从未使用过feathersjs,但只要查看该配置文件,github 属性
successRedirect就会出现在我身上。这可能是它用于redirect_uri的东西吗?在这种情况下,您需要将其更新为localhost以外的其他内容。我还对您如何到达为 GitHub 中的回调配置的/auth/github/callback路径感到困惑。该路径不应该与您在successRedirect中配置的路径匹配吗? -
嗨,马克,感谢您的回答。 successRedirect 是羽毛后端在一切顺利时将您重定向到的链接。我认为发生的事情是:您访问backend/auth/github。 Feathers 将您重定向到 Github。您批准访问。 Github 将您重定向到羽毛后端 (backend/auth/github/callback)。如果一切成功,feathers 会将您重定向到 successRedirect URI。所以我认为这无关紧要。但如果我错了,也许有人可以纠正我?
-
您是否在 GitHub 上的应用程序配置中设置了错误消息并设置了相同的 URL?此外,生产应用程序预计将在端口 80 上运行。
-
嗨达夫,感谢您的回答。它是相同的 URL。我尝试在端口 80 上使用 sudo 运行该应用程序(两者之间没有 nginx)。我尝试了指定 callbackURL 而没有在 default.json 中指定 callbackURL。它仍然不起作用。 github上的网址是一样的。就像在屏幕截图中一样。
标签: node.js amazon-web-services amazon-ec2 feathersjs feathers-authentication