ngx-oauth2-client
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

NgxOauth2Client

Simple package to manage OAuth2 authentication in the angular client side. For now only password flow is supported.

To start, install it:

#package installation 
npm install ngx-oauth2-client

Feature

The service is a singleton, so is possible to use authentication information/functionality from everywhere.

The package save by default information in the cookie, so it's not necessary login every page refresh.

For now the only one provided flow are password

  • login(username, password)
  • login from cookie
  • logout

How to use

It's necessary configure the login/logout end-point.

Oauth2Service.setUrl('auth.example.com');

This is an example of the main usage of the package

OAuth2Service.setUrl('http://example.com');
if (oauth2.loginFromCookie()) { //oauth2 var is Injected
  oauth2.login('name@example.com', 'password')
    .subscribe(() => {
      //success .... 
    });
} else {
  //success ...
}

Readme

Keywords

none

Package Sidebar

Install

npm i ngx-oauth2-client

Weekly Downloads

8

Version

0.0.1

License

none

Unpacked Size

87.9 kB

Total Files

23

Last publish

Collaborators

  • leo-sgruz