vue-identity
vue-identity
is a vue plugin that uses JSON Web Tokens to make authentication easy.
Installation
NPM
$ npm install vue-identity
Example
Vue
Authenticate
This will ask the server for an accessToken
by passing it a refreshToken
. Cookies are sent with this request if you prefer.
this$identity
Login
Request a new accessToken
and refreshToken
by passing credentials to the server. Credentials are sent as parameters of login and are POST
ed to the server.
this$identity
In your html, you can access the user
state
Hello {{$identity.user.name}}
Vue Resource Interceptor
After authenticating, an interceptor is added to vue-resource
that sends the accessToken
in the Authorization
header as a Bearer token.