restful authentication - AUTHORIZATION_REQUIRED error when running Strongloop with PM2 in cluster mode -


i'm running strongloop using pm2 process manager.

  • pm2 start server/server.js -i 0 (starts strongloop in cluster mode).
  • pm2 list (shows me 2 instances of server different pid). pm2 list image example

in angular-fullstack application:

  • run post call email , password token, ttl etc. response correct: {"id":"z2mgpdn2dyxhhww2dlhai026vhbgxw43jpcz9khwa7u9gykamnqzaaexv2nvevq8","ttl":1209600,"created":"2016-07-21t16:47:34.020z","userid":"571609e4c88c6db26b75aacd"}
  • run get call using id (token) more information user: http://myrestservice.com:3000/api/users/571609e4c88c6db26b75aacd?access_token=z2mgpdn2dyxhhww2dlhai026vhbgxw43jpcz9khwa7u9gykamnqzaaexv2nvevq8 the response error 401 authorization_required

question!!: how can configure strongloop handle multiple instances of same server/server.js ? read configure stored redis session, guides talks express + redis stored session management. think different approach.


thanks in advance!

it seems not persisting accesstokens on common datasource running servers/processes.

try inspecting model-config.json file , verify datasource accesstoken model shared.

this not shared between servers/processes:

"accesstoken": {   "datasource": "memory",   "public": false }, 

this shared between servers/processes:

"accesstoken": {   "datasource": "mysqlds",   "public": false }, 

*where mysqlds stored on mysql

this relevant section of loopback docs configuring datasources https://docs.strongloop.com/display/public/lb/attaching+models+to+data+sources#attachingmodelstodatasources-makethemodelusethedatasource


Comments