简体   繁体   English

在Http Post上添加授权标头

[英]Add Authorization Header on Http Post

是否可以在Http Post上添加授权标头,我想在我的MVC项目中使用OAuth Providers,在那里我想将我的秘密令牌设置为Authorization标头。

Follow these steps. 跟着这些步骤。 Initially when user clicks on login, send a ajax request to Authorization server(OAuth Bearer) with the data - granttype=password&username=xxx&password=yyy 最初,当用户单击登录时,将ajax请求与以下数据一起发送到授权服务器(OAuth Bearer)-granttype = password&username = xxx&password = yyy

On the success, store the generated token in localstorage Authorization header needs to be set from client side when making a request to webapi or mvc. 成功时,将生成的令牌存储在localstorage授权标头中时,需要在向Webapi或mvc发出请求时从客户端进行设置。 Authorization: Bearer generatedbearertokenvalue 授权:不记名生成的bearertoken值

You need to decorate the controller/action with [Authorize] attribute 您需要使用[Authorize]属性装饰控制器/动作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM