9.0.0 • Published 4 years ago

a4-http-authorization-interceptor v9.0.0

Weekly downloads
2
License
MIT
Repository
-
Last release
4 years ago

a4-http-authorization-interceptor

Angular 7 Http Authorization Interceptor

How-To

Install

npm install a4-http-authorization-interceptor

app.module.ts

  1. Add HttpAuthorizationModule to imports of the app.module.ts.
...
import { HttpAuthorizationModule } from 'a4-http-authorization';
...

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    ...,
    HttpAuthorizationModule,
    ...
  ],
  ...
})

Inject the service

constructor(private httpAuthorizationService: HttpAuthorizationService) { }

Set the token's cookie name

this.httpAuthorizationService.setTokenCookieName('oauth-cookie');

Set Authroization Header Call Back

this.httpAuthorizationService.setHttpAuthorizationCallback(req => {
  // your logic here

  return true; // return true to allow injector to inject the authorization header
               // return false and injector will not inject the authorization header
});

Get Authorization Header

const header = this.httpAuthorizationService.getAuthorizationHeader();

This will return Bearer <token> if cookie is found, otherwise it returns an empty string ('').

9.0.0

4 years ago

8.0.0

5 years ago

7.0.0

6 years ago

6.0.2

6 years ago

6.0.1

6 years ago

6.0.0

6 years ago

5.0.3

6 years ago

5.0.2

6 years ago

5.0.1

7 years ago

5.0.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago