0.0.6 • Published 6 years ago
angular-jwt-coda v0.0.6
Links
Table of contents
Getting Started
ng-jwt-authentication contains all HttpClient methods bundled with JWT authentication with refresh token.
Installation instructions
Install ng-jwt-authentication
from npm
:
npm install ng-jwt-authentication --save
Add needed package to NgModule imports:
import { AngularJwtModule } from 'ng-jwt-authentication';
const config = {
refreshUrl: string, //optional
headerKeyName: string, //optional
accessTokenKey: string, //optional
refreshTokenKey: string, //optional
expiresInKey: string, //optional
errorStatusCode: number //optional
};
@NgModule({
...
imports: [AngularJwtModule.forRoot(config),...]
...
})
Add service to your page:
import { AngularJwtService } from 'ng-jwt-authentication';
...
constructor(private httpService: AngularJwtService, ...) {
...
}
someMethod() {
this.httpService.jwtAuthPost('YOUR-API-URL-HERE', data, headers).subscribe((data) => {
...
}, (error) => {
...
});
}
API
API contents:
jwtAuthGet(url
, options
])
Method to send get request with jwt token.
argument | type | description |
---|---|---|
url | string | Request url |
options | object | Optional. { customHeaders?: HttpHeaders; observe?: any } Send custom headers in the request. Set observe: 'response' to get complete response. Default is observe: 'body' . |
Usage & Demo
Main source of API documentation and usage scenarios available here: https://addons.coda.global/
Additionally you can find demos and docs deployed from latest code with angular v6
How to build lib for development
To run the wrapper project:
- clone repository
npm install
ng serve
To update library and check the changes:
- Go to projects > angular-jwt
ng build angular-jwt
_*// it will build the changes in library and serve it to the wrapper project.
Contribution
Are very welcome! And remember, contribution is not only PRs and code, but any help with docs or helping other developers to solve issues are very appreciated! Thanks in advance!
License
MIT