我想使用 Restify/Nodejs + Oauth2 + Mongodb 来注册和验证用户......我在这里找到了一个很棒的 git hub 存储库:
https://github.com/rgallagher27/node-restify-oauth2-mongodb
我同时安装了 Redis 和 Mongo,我使用代码启动并运行了节点,我可以注册用户。但是,我在验证用户时遇到了一些问题。说明中有一个步骤我不确定我是否正确完成...
//////////////////////
**Insert a Client Key into the mongoDB wit the format:**
{
_id: ObjectId("51c6e846ede91c0b8600005e"),
clientName: "Test Client",
client: "test",
secret: "password"
}
//////////////////
这应该是一个mongo db,如
db.ClientKey.insert({_id: ObjectId("51c6e846ede91c0b8600005e"), clientName: "Test Client", client: "test", secret: "password"});
或者这是一个集合?
我都试过了都没有用。
我相信我无法理解如何在 mongoDB 中创建它可能导致我无法验证用户的问题
在 mongodb 我的 restify_test 数据库有一个“用户”集合......它显示为
> db.users.find();
{
"name" : "Test",
"email" : "test@test.com",
"username" : "tester1",
"hashed_password" : "$2a$10$67rLfuKQqHIwHc2tOPNu.ejY.L/5Mk6XnuOdn0xc9UXUyzKBs6NQC",
"_id" : ObjectId("520d5874421b580000000001"),
"role" : "Admin",
"__v" : 0
}
>
但是当我尝试卷曲登录时
$ curl --user test:password --data grant_type=password --data username=tester1 --data password=testing27 http://[my-localhost]:8090/token
{"error":"invalid_client","error_description":"Client ID and secret did not validate."}
我再次感谢您在这里给我的任何指导。