loopback logout access_token is required

603 Views Asked by At

I want to test loopbacks logout endpoint. But it returns access_token is required. what is the correct JSON body to feed or the loopback user logout endpoint?

1

There are 1 best solutions below

2
Sashi On

This code snippet will logout your user.

User.logout('asd0a9f8dsj9s0s3223mk', function (err) {
         console.log(err || 'Logged out');
       });

Reference

I assume you aren't setting the access token on the Loopback API Explorer.

You will find this access token section on the top right corner of your API Explorer.

API Explorer

  1. Copy the access token returned by the login API here.
  2. Paste it on the accessToken section and click 'Set Access Token'
  3. Try calling the logout API now

UPDATE

To call from a client. Add the Access token as a query parameter or header.

ACCESS_TOKEN=6Nb2ti5QEXIoDBS5FQGWIz4poRFiBCMMYJbYXSGHWuulOuy0GTEuGx2VCEVvbpBK

# Authorization Header
curl -X GET -H "Authorization: $ACCESS_TOKEN" \
http://localhost:3000/api/widgets

# Query Parameter
curl -X GET http://localhost:3000/api/widgets?access_token=$ACCESS_TOKEN

Reference