我在github上创建了一个带有FeathersJS后端的Oauth流。在localhost上运行此程序时,所有操作都很好。目前,我正在EC2上测试对AWS的部署,而在EC2实例上,我无法使流程正常工作。我拿到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
}
}
}production.json
{
"host": "my-ec2-instance.compute.amazonaws.com",
"port": "3030"
}Github配置

编辑:将succesRedirect更改为"/“
发布于 2017-11-03 08:44:15
好的,我找到了这个问题的解决方案。在生产模式下,羽毛应用程序仍然从default.json获取URL来构建回调URL。因此,生产URL不仅应该在production.json中填充,而且在default.json中也应该输入相同的URL。
发布于 2017-10-29 14:36:21
查看这个人的博客文章中的示例代码,您似乎需要在github配置部分添加一个callbackURL参数,其值与您在GitHub 授权回调URL设置中配置的值相同。
此外,我认为在github.successRedirect服务器上运行时,需要将http://my-ec2-instance.compute.amazonaws.com:3030/redirect设置修改为http://my-ec2-instance.compute.amazonaws.com:3030/redirect,因为在EC2上运行时,您配置的localhost默认值肯定无法工作。
https://stackoverflow.com/questions/47000788
复制相似问题