Skip to content

Instantly share code, notes, and snippets.


gdyrrahitis/auth.service.ts Secret

Created Aug 18, 2018
What would you like to do?
authenticate(username: string, password: string): Observable<any> {
let headers = new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded' });
let body = new URLSearchParams();
body.set('username', username);
body.set('password', password);
body.set('grant_type', "password");
body.set('client_id', "angular.client");
body.set('client_secret', "secret");
return<any>(this.url, body.toString(), {
headers: headers
map(jwt => {
if (jwt && jwt.access_token) {
localStorage.setItem('token', JSON.stringify(jwt))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment