Skip to content

ruiaraujo/angular-jwt-decode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

angular-jwt-decode - Use jwt_decode from an Angular Controller or Service

Inspired by https://github.com/andresesfm/angular-underscore-module

Usage

  1. get it

    bower install angular-jwt-decode

  2. Add angular-jwt-decode.js to your main file (index.html)

    <script src="bower_components/angular-jwt-decode/angular-jwt-decode.js"></script>

  3. Add the module as a dependency in your App definition

var myapp = angular.module('MyApp', ['jwt-decode'])


4. To use, add as an injected dependency to your Controller/Service and it is ready to use

~~~javascript
angular.module('MyApp').controller('MyCtrl', function ($scope, JwtDecode) {
var token = 'eyJ0eXAiO.../// jwt token';

var decoded = JwtDecode.decode(token);
console.log(decoded);

/* prints:
* { foo: "bar",
*   exp: 1393286893,
*   iat: 1393268893  }
*/
~~~

##References:

jwt-decode:https://github.com/auth0/jwt-decode


Inspiration for this module: https://github.com/andresesfm/angular-underscore-module

About

Inject jwt-decode in your Angular Controllers and Services.

Resources

Stars

Watchers

Forks

Packages

No packages published