I'using Angular 4 + ASP MVC 5 WEB API and I've integrated Token Authentication code from here and I can get token from Poster using POST to http://localhost:3590/Token
How to use this authentication in Angular 4? thanks
Here is my code, replace your username, password and port number. You can check the token in session storage.
Login():void{
const body='username=1@1.com&password=Zx123.&grant_type=password';
let resp=this.http.post('http://localhost:11694/token',body,
{observe:'response'}).subscribe(res=>{
sessionStorage.setItem('myToken',res.body['access_token']);
}
);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.