Skip to content

Latest commit

 

History

History
30 lines (24 loc) · 1.09 KB

README.md

File metadata and controls

30 lines (24 loc) · 1.09 KB

angular-access-token

Access Token module for AngularJs. You can use this module if use the approach of access tokens to store security credentials for a login session which identifies the user.This module is very useful if you consume password or user credentials grant of oauth2 for user authentication.

Installation

# Bower
bower install angular-access-token --save

# NPM
npm install angular-access-token --save

Usage

var app = angular.module('MyApp', ['htAccessToken']);

app.controller('LoginCtrl', ['htAccessTokenManager', function(accessTokenManager) {
    // store access token in local storage with expiry of 3600 seconds
    accessTokenManager.setToken('sadfsadf', 3600);
    console.log(accessTokenManager.hasToken()); // true
    console.log(accessTokenManager.getToken()); // sadfsadf
}]);

// for using token interceptor to automatically send token as Authorization header
app.config(function ($httpProvider) {
    $httpProvider.interceptors.push('htAccessToken.interceptor');
});