AntiForgeryToken与通过WebAPI的OAuth搭配使用效果不佳 [英] AntiForgeryToken does not work well with OAuth via WebAPI

查看:71
本文介绍了AntiForgeryToken与通过WebAPI的OAuth搭配使用效果不佳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试使具有Oauth(Gmail)授权的MVC4应用程序可以通过WebAPi访问.我们制作了一个WebAPI控制器来返回数据列表,但是我们不能使authorize属性正常工作.

We are trying to make a MVC4 app with Oauth (Gmail) authorisation accessible via a WebAPi. We made a WebAPI controller that returns a list of data, but we cannot put the authorise attribute to work properly.

现在很难将AntiForgeryToken正确发送到服务器,并且我们会收到一个session_requestverificationtoken错误.

Right now it is difficult to send the AntiForgeryToken correctly to the server and we get a session_requestverificationtoken error.

是否有很好的方法通过Webai解析和发布正确的防伪令牌?还是有更好的方法通过Webapi通过OAuth登录?

Is there a good way to parse and post the correct antiforgery token via Webai? Or is there a better way to login via OAuth via a webapi?

推荐答案

为什么要在Web API中使用AntiForgeryToken?没必要,只需使用OAuth对您的请求进行身份验证即可.他们无意一起工作.

Why are you using an AntiForgeryToken with Web API? It's not necessary, just authenticate with your request with OAuth. They are not meant to work together.

这篇关于AntiForgeryToken与通过WebAPI的OAuth搭配使用效果不佳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆