LoopBack API Explorer-Set Access Token -02.

Ahmed Thaajwer
D6 Digital
Published in
3 min readJul 12, 2019

The built-in access token model represents the access token that LoopBack creates for an authenticated user.

In this post, I am going to describe you to how to set an access token.

  • First of all, you have to open your loopback app by using node . command
  • Click the model person. You will get something like this.
  • Now I am going to input some information to the hello-loop app. for these go to (person->post->data(Input your data)->try it out.
  • you will get your data into the response body as shown below.
  • Now go to Get and click Try it out button to filter the all data that we have already input.

Here we get our all input data without any problem.

  • let’s discuss the ACLs. ACLs (Access Control Lists) are how you define who can do what with your content. Out of the box, LoopBack allows anyone to do anything. That means an anonymous user can create, read, update, and delete content. This is great for testing, but not great for production. You can use the command line to add these ACLs by using lb acl command. The commands line will prompt you for what you want to lockdown.

The generator guides you through creating your ACLs. Enter the values highlighted in green. To accept the default, just press Enter.

  • After creating ACL, run the node . command again and check the hello-loop application by clicking Try it out button in the GET(person->GET/people->try it out)
  • Here, you cannot see the earlier updated details. because we created an access control list.Even though all the users cannot show the data.
before access token setup
  • So that we need to set the access token of the particular user. First, we have to update the login information(email and password) of the particular user. (User->POST/User->data(input email and password)->Try it Out).
  • I have updated sample email and password.

{
“email”: “
ahmed@gmail.com”,
“password”:”12345"
}

  • Then go to User ->POST/User/login-> credentials and input the same data that we have input above.

{
“email”: “
ahmed@gmail.com”,
“password”:”12345"
}

  • Then click ‘Try it out’, you will get like this in the response body.
  • Here id is the access token for the particular user. copy the id and paste it into the top of the access token space and click set access token button.
token set
  • Here now token has set.
  • Now again go to the person model and update the data and check.
after access token setup.
  • yeah, now it's working.

Thank you for reading.😊

--

--

Ahmed Thaajwer
D6 Digital

B.Sc.(hons) in Computing & Information System(SUSL). Former Software Engineer@D6 Digital. IEEE Brand Ambassador@IEEE. Regional Country Director@UYG.