Closed GuillaumeCz closed 6 years ago
Hello @andre-lima ! I finaly figured out how to properly create a user for the admin interface and request's token. The data of #95 aren't correct because these steps are a little bit more complicated...
The follow steps might help you :
Create an Entity with the admin interface or Postman
{ "domain": "testdomain.xyz", "username": "testuser", "passwordHash": "33f1ba50d3acdfe04fadbfcdc50edd84a3af0f9d377872003eaedbb68f8e6d7146e87c35e5f3338341d91b84c1371a6a9db054c4104797e99848f4d2d8a2b91e", "passwordSalt": "694658b93aa9c2f245cca37da3b4d7cc", "admin": true, "authoritative": true }
The password is the cryptografic Hash of the string "testpass", the password that you will use later to login
Create a Client which references the previous entity
{ "entityId": "<Your Entity"s ID ! >", "clientName": "testuser", "deviceType": "other", "clientId": "testuser", "clientSecret": "testuserSecret", "redirectUri": "https://www.getpostman.com/oauth2/callback", "isTrusted": false, "deviceTypeProper": "Other" }
Try to login on the admin interface (username : "testuser", password= "testpass")
If it work you can try to request an access token with Postman using the right parameters
I hope it works ;)
From @andre-lima on December 18, 2017 16:24
I still get "Unauthorized" on step 2. Can you show me what you put for the Authorization, Headers and Body tabs, in Postman?
Try to put https://www.getpostman.com/oauth2/callback in the callback url field.
I can't try it now but let me know if this can help you ;)
You might need also to bypass the authentication system by removing the authentication/admin check on the routes, this will permit you to create the first entity and client with the admin interface ;)
in order to do that : replace router.route('/') .get(authCtrl.authenticateUser, authCtrl.ensureAdmin, adminCtrl.index);
with router.route('/') .get(adminCtrl.index);
this will allow you to access the index page of the admin interface. Do the same thing for the entity and client routes.
Hope that will help, you. I will try to manage to check this deeper this evening of night ;)
From @andre-lima on December 20, 2017 15:51
I'm having problems on the Postman side. I'll try overwriting the auth flow directly later, like you suggested.
From @andre-lima on December 15, 2017 18:25
It may be that i'm not using the right configuration, but i'm not managing to make requests to sylow from Postman.
STEPS TO REPRODUCE
DISPLAYED ON THE LOGIN WINDOW
{"message":"Forbidden","stack":"APIError: Unauthorized client\n at new ExtendableError (/home/adantas/Documents/sylow/dist/server/helpers/ExtendableError.js:18:11)\n at new APIError (/home/adantas/Documents/sylow/dist/server/helpers/APIError.js:29:5)\n at app.use (/home/adantas/Documents/sylow/dist/config/express.js:171:22)\n at Layer.handle_error (/home/adantas/Documents/sylow/node_modules/express/lib/router/layer.js:71:5)\n at trim_prefix (/home/adantas/Documents/sylow/node_modules/express/lib/router/index.js:310:13)\n at /home/adantas/Documents/sylow/node_modules/express/lib/router/index.js:280:7\n at Function.process_params (/home/adantas/Documents/sylow/node_modules/express/lib/router/index.js:330:12)\n at next (/home/adantas/Documents/sylow/node_modules/express/lib/router/index.js:271:10)\n at /home/adantas/Documents/sylow/node_modules/express/lib/router/index.js:618:15\n at next (/home/adantas/Documents/sylow/node_modules/express/lib/router/index.js:256:14)\n at next (/home/adantas/Documents/sylow/node_modules/express/lib/router/route.js:121:14)\n at Layer.handle_error (/home/adantas/Documents/sylow/node_modules/express/lib/router/layer.js:67:12)\n at next (/home/adantas/Documents/sylow/node_modules/express/lib/router/route.js:129:13)\n at validated (/home/adantas/Documents/sylow/node_modules/oauth2orize/lib/middleware/authorization.js:135:31)\n at _client2.default.findOne.then.client (/home/adantas/Documents/sylow/dist/server/helpers/OAuth.js:123:23)\n at tryCatcher (/home/adantas/Documents/sylow/node_modules/bluebird/js/release/util.js:16:23)\n at Promise._settlePromiseFromHandler (/home/adantas/Documents/sylow/node_modules/bluebird/js/release/promise.js:510:31)\n at Promise._settlePromise (/home/adantas/Documents/sylow/node_modules/bluebird/js/release/promise.js:567:18)\n at Promise._settlePromise0 (/home/adantas/Documents/sylow/node_modules/bluebird/js/release/promise.js:612:10)\n at Promise._settlePromises (/home/adantas/Documents/sylow/node_modules/bluebird/js/release/promise.js:691:18)\n at Async._drainQueue (/home/adantas/Documents/sylow/node_modules/bluebird/js/release/async.js:138:16)\n at Async._drainQueues (/home/adantas/Documents/sylow/node_modules/bluebird/js/release/async.js:148:10)"}
DISPLAYED ON THE SERVER