Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

neroniaky/angular-token

Repository files navigation

Angular-Token

npm versionnpm downloadsBuild StatusAngular Style Guide

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

👋 This library has been renamed toAngular-Token! Please follow themigration guide.


Quick Links


Install

  1. Set up a Rails withDevise Token Auth

  2. Install Angular-Token via NPM with

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

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

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

Use

  1. Register your user

    constructor(privatetokenService:AngularTokenService){}this.tokenService.registerAccount({login:'example@example.org',password:'secretPassword',passwordConfirmation:'secretPassword'}).subscribe(res=>console.log(res),error=>console.log(error));
  2. Sign in your user

    constructor(privatetokenService:AngularTokenService){}this.tokenService.signIn({login:'example@example.org',password:'secretPassword'}).subscribe(res=>console.log(res),error=>console.log(error));
  3. Now you can use HttpClient to access private resources

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

Contributors


Jan-Philipp Riethmacher

Arjen Brandenburgh

License

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors29


[8]ページ先頭

©2009-2025 Movatter.jp