# Epom-ng2-token-service
Service implements token renew functionality. It used in `epom-ng2-api-service` in `CloudStrategy`.

## Getting Started

This module depends on `epom-ng2-storage-service`

### Prerequisites

| Name | Description |
| ---- | ----------- |
| `epom-ng2-storage-service` | need to get `TokenExpred` property from localStorage |


Install `epom-ng2-storage-service` via npm:

```sh
$ npm install --save epom-ng2-storage-service
```

### Installing

You need to provide it into your app.module
```typescript
    import {TokenService} from 'epom-ng2-token-service';
    ...
    providers: [
        TokenService,
        ...
    ];
```
That's all, this service works inside the  `CloudStrategy` of `epom-ng2-api-service` and provided by default.

## Parts
    .
    |-- epom-ng2-token-service
    |   |--index

## Service public methods
| Method Declaration                                                      | Description |
| ----------------------------------------------------------------------- | ----------- |
| .**mustRenewToken**(url: string, isGetRequest: boolean): boolean  | returns true if you need renew token and false if you don't |
| .**getTokenStream**(): Observable  | return Observable with renew token request |
| .**generateTokenHeaders**(options: RequestOptionsArg): RequestOptionsArgs  | returns new modified RequestOptionsArgs with headers for token renew |

## Contributors

Gennady Strelets <g.strelets@itmgmedia.net>
