Allow loopback application to use previous access token

 ̄綄美尐妖づ 提交于 2019-12-06 05:57:55

Your access token is getting stored by default in loopback memory. Therefore, it persists only until the application is restarted.

open server/model-config.json

"AccessToken": {
    "dataSource": "db",
    "public": false
  }

This is the initial configuration of the Access Tokens. See here the storage datasource is db which is loopback memory. You need to change this to your MongoDB or some other storage

You need to store Access Tokens in the database rather in the memory.

For example lets store this to the mongoDb storage.

  1. Assuming you already have mongodb installed in your system. Install the mongodb connector. In console type

    npm install loopback-connector-mongodb

  2. Now configure the server/datasources.json file. Add this line to this file.

    "mongodb": { "host": "0.0.0.0", "port": 27017, "database": "MONGODB DATABASE NAME", "password": "MONGODB PASSWORD", "name": "MONGODB NAME", "connector": "mongodb", "user": "YOUR USER NAME" }

  3. Open server/model-config.json. change this db to mongodb

    "AccessToken": { "dataSource": "mongodb", "public": false }

Now run the loopback server `Acces Tokens will be there even after restarting the application.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!