socialnetworknews-web

A open-source Paper.li clone
git clone git://archive.git.mtrnord.blog/SocialNetworkNews/socialnetworknews-web.git
Log | Files | Refs | README | LICENSE

commit eaf8c65a2a1c685052bec853811bfe394b2c0386
parent 870833c6dcf4b155c4583484e7ac888a13dcb5ce
Author: MTRNord <mtrnord1@gmail.com>
Date:   Sat, 31 Mar 2018 21:56:27 +0200

Pass AuthToken to APIService for later use

Diffstat:
Msrc/app/api.service.ts | 1+
Msrc/app/callback/twitter/twitter.component.ts | 5+++--
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/app/api.service.ts b/src/app/api.service.ts @@ -44,6 +44,7 @@ export interface Author { @Injectable() export class ApiService { url: string; + authToken: string; constructor(@Inject(DOCUMENT) private document, private http: HttpClient) { this.url = document.location.protocol + '//' + document.location.hostname + '/api'; } diff --git a/src/app/callback/twitter/twitter.component.ts b/src/app/callback/twitter/twitter.component.ts @@ -12,6 +12,7 @@ import 'rxjs/add/operator/concat'; import 'rxjs/add/observable/throw'; import {HttpClient} from '@angular/common/http'; import {DOCUMENT} from '@angular/common'; +import {ApiService} from '../../api.service'; @Component({ selector: 'app-twitter', @@ -23,7 +24,7 @@ export class TwitterComponent implements OnInit { oauth_token: string; oauth_verifier: string; - constructor(private toastr: ToastrService, private route: ActivatedRoute, @Inject(DOCUMENT) private document, private http: HttpClient) { + constructor(private apiService: ApiService, private toastr: ToastrService, private route: ActivatedRoute, @Inject(DOCUMENT) private document, private http: HttpClient) { this.url = document.location.protocol + '//' + document.location.hostname + '/api'; } @@ -53,7 +54,7 @@ export class TwitterComponent implements OnInit { }) .subscribe( data => { - // TODO get accessToken Header + this.apiService.authToken = data.headers.get('authorization'); }, err => { this.toastr.error(err['error'], 'Error connecting API', {