【问题标题】:Asp Net 5 Web Api token authentication in Angular 4Angular 4 中的 Asp Net 5 Web Api 令牌身份验证
【发布时间】:2017-10-12 12:25:09
【问题描述】:

我正在使用 Angular 4 + ASP MVC 5 WEB API,并且我已经集成了令牌身份验证 code from here 我可以使用 POST 从海报中获取令牌到 http://localhost:3590/Token

如何在 Angular 4 中使用此身份验证? 谢谢

【问题讨论】:

    标签: asp.net asp.net-mvc angular asp.net-web-api


    【解决方案1】:

    这是我的代码,替换您的用户名、密码和端口号。您可以在会话存储中检查令牌。

    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']);
        }
    );
    }
    

    Screenshot

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-09
      • 2014-09-08
      • 2015-12-25
      • 1970-01-01
      • 2014-06-14
      • 1970-01-01
      • 2017-02-05
      • 2018-05-27
      相关资源
      最近更新 更多