oauth2orize示例返回AuthorizationError:未授权

时间:2014-10-19 17:12:05

标签: oauth-2.0 oauth2orize

我已经下载了文档中建议的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'
};

1 个答案:

答案 0 :(得分: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连接的客户端。