【问题标题】:oauth2orize sample returns AuthorizationError: not authorizedoauth2orize 示例返回 AuthorizationError: not authorized
【发布时间】:2014-12-14 16:44:12
【问题描述】:

我已下载文档中建议的 oauth2orize provider code examplesample oauth client,但出现以下错误:

500 AuthorizationError: 在验证时未授权 (/Users/trevorallred/projects/pics/node-soa/oauth2orize/examples/all-grants/node_modules/oauth2orize/lib/middleware/authorization.js:131:36) 在 /Users/trevorallred/projects/pics/node-soa/oauth2orize/examples/all-grants/oauth2.js:180:14 在 Object.exports.findByClientId (/Users/trevorallred/projects/pics/node-soa/oauth2orize/examples/all-grants/db/clients.js:24:10) 在exports.authorization.res.render.transactionID (/Users/trevorallred/projects/pics/node-soa/oauth2orize/examples/all-grants/oauth2.js:174:16) 在 /Users/trevorallred/projects/pics/node-soa/oauth2orize/examples/all-grants/node_modules/oauth2orize/lib/middleware/authorization.js:167:9 通过 (/Users/trevorallred/projects/pics/node-soa/oauth2orize/examples/all-grants/node_modules/oauth2orize/lib/server.js:262:26) 通过时 (/Users/trevorallred/projects/pics/node-soa/oauth2orize/examples/all-grants/node_modules/oauth2orize/lib/server.js:280:9) 通过时 (/Users/trevorallred/projects/pics/node-soa/oauth2orize/examples/all-grants/node_modules/oauth2orize/lib/server.js:271:11) 在 Server._parse (/Users/trevorallred/projects/pics/node-soa/oauth2orize/examples/all-grants/node_modules/oauth2orize/lib/server.js:285:5) 经授权 (/Users/trevorallred/projects/pics/node-soa/oauth2orize/examples/all-grants/node_modules/oauth2orize/lib/middleware/authorization.js:118:12)

我在这里运行客户端:http://localhost:3002/ 我单击“与 example-oauth2orize 连接”的链接

它将我重定向到提供者:http://localhost:3000/login

使用“bob”登录后,我被发送到此错误页面。

我所做的唯一修改是示例客户端中的 oauth-config.js。

'use strict';

module.exports = {
        provider: {
                protocol: "http",
                host: "localhost:3000",
                profileUrl: "/api/userinfo"
        },
        consumer: {
                protocol: "http",
                host: "localhost:3002"
        }
};

我在看到this bug report 后尝试修改 oauth-consumer-config.js,但它似乎没有改变任何行为。

module.exports = {
  name: 'Example Consumer App'
, icon: 'http://example.com/icon_64.png'
, clientId: 'trevorclient'
, clientSecret: 'kasdfasdfoq34t134tg109gqerg1gjc'
};

【问题讨论】:

    标签: oauth-2.0 oauth2orize


    【解决方案1】:

    尝试将您的 oauth-consumer-config.js 文件更新为:

    module.exports = {
      name: 'Example Consumer App'
    , icon: 'http://localhost:3000/icon_64.png'
    , clientId: 'abc123'
    , clientSecret: 'ssh-secret'
    };
    

    问题在于all-grants 示例实际上并未使用数据库,而是出于说明目的使用平面文件。如果您导航到 all-grants 项目中的 db/clients.js,您将看到那里列出的允许通过 OAuth 连接的客户端。

    【讨论】:

      猜你喜欢
      • 2021-10-30
      • 2022-10-17
      • 2013-09-05
      • 2015-08-03
      • 2017-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多