Regarding (Angular SDK) User.logout(), I'm a bit confused as the doc stated that:
parameters Object Request parameters. This method does not accept any parameters. Supply an empty object or omit this argument altogether.
I'm doing exactly that in my angular authentication controller, but server keeps spitting out:
'Unhandled error for request POST /api/Readers/logout: Error: accessToken is required to logout'
which obviously means it's expecting the current user's accessToken to log her/him out. The token is also included in the post request under 'authorization'.
What am I doing wrong here? I have not been able to find an example user logging in/out example for Angular SDK.
Vu
you should configure the SDK so that the authorization header is provide with the user's access token.
User.logout() expects an logged-in user hence, an access token.
see: https://loopback.io/doc/en/lb2/AngularJS-JavaScript-SDK.html#client-configuration
What is a proper example of User.logout() call?
Is it
User.logout({}, {
accessTokenId: user.token
}, function() {}, function() {})
or something else?
I have tried different calls including setting header but still getting 401 error complaining about missing accessToken.
Actually I have figured this out. I forgot to add authentication.js script to server/boot...
Most helpful comment
Actually I have figured this out. I forgot to add authentication.js script to server/boot...