· 7 years ago · Feb 20, 2018, 07:30 PM
1@Injectable()
2export class HttpService {
3
4 constructor(private http: HttpClient) { }
5 public login(email, password) {
6 const aUsername = "client";
7 const aPassword = "clientpassword";
8 const headers: HttpHeaders = new HttpHeaders();
9 headers.append("Content-Type", "application/x-www-form-urlencoded");
10 headers.append("Authorization", "Basic" + btoa(aUsername + ':' + aPassword));
11 const params = { grant_type: "password", username: email, password: password };
12 console.log(address + "/oauth/token", params, {headers: headers});
13 return this.http.post(address + "/oauth/token", params, {headers: headers});
14}
15}