0.0.1 • Published 6 years ago
ngx-oauth2-client v0.0.1
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 ...
}
0.0.1
6 years ago