]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/core/scoped-tokens/scoped-tokens.service.ts
emit more specific status codes on video upload (#3423)
[github/Chocobozzz/PeerTube.git] / client / src / app / core / scoped-tokens / scoped-tokens.service.ts
CommitLineData
5beb89f2
RK
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}