Awesome Open Source
Awesome Open Source


npm version npm downloads Build Status Angular Style Guide

🔑 Token based authentication service for Angular with interceptor and multi-user support. Works best with the devise token auth gem for Rails.

👋 This library has been renamed to Angular-Token! Please follow the migration guide.

Quick Links


  1. Set up a Rails with Devise Token Auth

  2. Install Angular-Token via NPM with

    npm install angular-token
  3. Import and add AngularTokenModule to your main module and call the 'forRoot' function with the config. Make sure you have HttpClientModule imported too.

    import { AngularTokenModule } from 'angular-token';
        imports: [
        declarations: [ ... ],
        bootstrap:    [ ... ]
  4. (Maybe Optional) Fix injection context runtime error After installing this package, if you get an Error: inject() must be called from an injection context when running your app, add the following to your typescript path config in the tsconfig[.app].json file:

    "paths": {
      "@angular/*": [ "./node_modules/@angular/*" ]


  1. Register your user

    constructor(private tokenService: AngularTokenService) { }
        login:                '[email protected]',
        password:             'secretPassword',
        passwordConfirmation: 'secretPassword'
        res =>      console.log(res),
        error =>    console.log(error)
  2. Sign in your user

    constructor(private tokenService: AngularTokenService) { }
        login:    '[email protected]',
        password: 'secretPassword'
        res =>      console.log(res),
        error =>    console.log(error)
  3. Now you can use HttpClient to access private resources

    constructor(http: HttpClient) { }
        res =>      console.log(res),
        error =>    console.log(error)


Jan-Philipp Riethmacher

Arjen Brandenburgh


The MIT License (see the LICENSE file for the full text)

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
typescript (11,218) 
angular (1,296) 
rails (660) 
authentication (473) 
oauth (169) 
auth (96) 
token (60) 
interceptor (47) 
devise (18)