Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
A

angular-token

> 前端框架
Open source

:key: Token based authentication service for Angular with interceptor and multi-user support. Works best with devise token auth for Rails. Example:

367 stars0 likes2 views
WebsiteGitHub

About

:key: Token based authentication service for Angular with interceptor and multi-user support. Works best with devise token auth for Rails. Example:

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

  • View to demo on Stackblitz
  • ✨ Learn about it on the docs site
  • Support us by contributing

Install

  1. Set up a Rails with Devise Token Auth

  2. Install Angular-Token via NPM with

    bash
    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.

    javascript
    import { AngularTokenModule } from 'angular-token';
    
    @NgModule({
        imports: [
            ...,
            HttpClientModule,
            AngularTokenModule.forRoot({
              ...
            })
        ],
        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:

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

Use

  1. Register your user

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

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

    javascript
    constructor(http: HttpClient) { }
    
    this.http.get('private_resource').subscribe(
        res =>      console.log(res),
        error =>    console.log(error)
    );

Contributors

| Jan-Philipp Riethmacher | [

Arjen Brandenburgh](https://github.com/arjenbrandenburgh) | :---: | :---: |

License

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

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptangularauthauthenticationdevise

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架