Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (27 sloc) 906 Bytes
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { MsalService } from '@azure/msal-angular';
import { Observable, of } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class UserlistService {
private url = "https://graph.microsoft.com/v1.0/users";
private permissions = ["user.read.all"];
private userList: Promise<any>;
constructor(private http: HttpClient, private msalService: MsalService) {
}
getUsers(): Promise<[]> {
var p = new Promise<[]>( (resolve, reject) => {
this.msalService.acquireTokenSilent(this.permissions)
.then(token => {
this.http.get<any>(this.url, {headers: {"Authorization": "Bearer " + token} })
.subscribe(
result => { resolve(result.value); },
error => { reject(error); }
)
})
});
return p;
}
}
You can’t perform that action at this time.