node.js - Problems using node-restify-oauth2-mongodb -
i use restify/nodejs + oauth2 + mongodb register , authenticate users... found great git hub repo here:
https://github.com/rgallagher27/node-restify-oauth2-mongodb
i have both redis , mongo installed , node , running code , can register users. however, have problems validating user. there 1 step in instructions not sure completing correctly ...
////////////////////// **insert client key mongodb wit format:** { _id: objectid("51c6e846ede91c0b8600005e"), clientname: "test client", client: "test", secret: "password" } //////////////////
should mongo db in
db.clientkey.insert({_id: objectid("51c6e846ede91c0b8600005e"), clientname: "test client", client: "test", secret: "password"});
or collection?
i have tried both no avail.
i believe failure understand how should created in mongodb may causing issues inability validate user
in mongodb restify_test db has "users" collections... 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 try curl 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 , secret did not validate."}
once again thank direction can give me here.
i had exact same problem when using insert statement:
db.clientkey.insert({_id: objectid("51c6e846ede91c0b8600005e"), clientname: "test client", client: "test", secret: "password"});
the thing noticed if did show collections in mongo, 1 collections called users , other clientkey. trial , error worked out collection needed called clientkeys (note plural , lowercase). should able run these commands fix issue (assuming you're working command line):
mongo use restify_test db.clientkey.renamecollection("clientkeys")
once did this, executing curl command correctly returned access_token , token_type.
hope helps!
Comments
Post a Comment