I would like to use Restify/Nodejs + Oauth2 + Mongodb to register and authenticate users... I found a great git hub repo here:
https://github.com/rgallagher27/node-restify-oauth2-mongodb
I have both Redis and Mongo installed and I get the node up and running with the code and I can register users. However, I have some problems with validating a user. There was one step in the instructions that I am not sure I am completing correctly ...
//////////////////////
**Insert a Client Key into the mongoDB wit the format:**
{
_id: ObjectId("51c6e846ede91c0b8600005e"),
clientName: "Test Client",
client: "test",
secret: "password"
}
//////////////////
Should this be a mongo db as in
db.ClientKey.insert({_id: ObjectId("51c6e846ede91c0b8600005e"), clientName: "Test Client", client: "test", secret: "password"});
or is this a collection?
I have tried both to no avail.
I believe my failure to understand how this should be created in mongoDB may be causing my issues with an inability to validate a user
in mongodb my restify_test db has a "users" collections... which appears as
> 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
}
>
But when i try to curl the login
$ 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."}
Once again I thank you for any direction you can give me here.