aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/scoped-tokens/scoped-tokens.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/core/scoped-tokens/scoped-tokens.service.ts')
-rw-r--r--client/src/app/core/scoped-tokens/scoped-tokens.service.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/client/src/app/core/scoped-tokens/scoped-tokens.service.ts b/client/src/app/core/scoped-tokens/scoped-tokens.service.ts
new file mode 100644
index 000000000..8e3697c31
--- /dev/null
+++ b/client/src/app/core/scoped-tokens/scoped-tokens.service.ts
@@ -0,0 +1,33 @@
1import { Injectable } from '@angular/core'
2import { HttpClient } from '@angular/common/http'
3import { environment } from '../../../environments/environment'
4import { AuthService } from '../auth'
5import { ScopedToken } from '@shared/models/users/user-scoped-token'
6import { catchError } from 'rxjs/operators'
7import { RestExtractor } from '../rest'
8
9@Injectable()
10export class ScopedTokensService {
11 private static BASE_SCOPED_TOKENS_URL = environment.apiUrl + '/api/v1/users/scoped-tokens'
12
13 constructor (
14 private authHttp: HttpClient,
15 private restExtractor: RestExtractor
16 ) {}
17
18 getScopedTokens () {
19 return this.authHttp
20 .get<ScopedToken>(ScopedTokensService.BASE_SCOPED_TOKENS_URL)
21 .pipe(
22 catchError(res => this.restExtractor.handleError(res))
23 )
24 }
25
26 renewScopedTokens () {
27 return this.authHttp
28 .post<ScopedToken>(ScopedTokensService.BASE_SCOPED_TOKENS_URL, {})
29 .pipe(
30 catchError(res => this.restExtractor.handleError(res))
31 )
32 }
33}