首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >托管在Oauth2上的带有羽毛的EC2 github连接

托管在Oauth2上的带有羽毛的EC2 github连接
EN

Stack Overflow用户
提问于 2017-10-29 13:34:51
回答 2查看 443关注 0票数 0

我在github上创建了一个带有FeathersJS后端的Oauth流。在localhost上运行此程序时,所有操作都很好。目前,我正在EC2上测试对AWS的部署,而在EC2实例上,我无法使流程正常工作。我拿到redirect_uri_error了。

代码语言:javascript
复制
{
"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:

代码语言:javascript
复制
{
  "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

代码语言:javascript
复制
{
  "host": "my-ec2-instance.compute.amazonaws.com",
  "port": "3030"
}

Github配置

编辑:将succesRedirect更改为"/“

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-11-03 08:44:15

好的,我找到了这个问题的解决方案。在生产模式下,羽毛应用程序仍然从default.json获取URL来构建回调URL。因此,生产URL不仅应该在production.json中填充,而且在default.json中也应该输入相同的URL。

票数 0
EN

Stack Overflow用户

发布于 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默认值肯定无法工作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47000788

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档