简体   繁体   English

Angular和Firefox告诉我我的OAuth调用响应错误,Fiddler告诉我否则

[英]Angular and Firefox tell me the response from my OAuth call is wrong, Fiddler tells me otherwise

I'm developing a Cordova app and need to authenticate via OAuth with my Drupal backend. 我正在开发Cordova应用程序,需要通过我的Drupal后端通过OAuth进行身份验证。 I'm trying to get a request token. 我正在尝试获取请求令牌。 I'm receiving a 200 response and with Fiddler I can see I'm getting my token: 我收到200的回复,并且通过Fiddler我可以看到我得到了令牌:

提琴手截图

I must say that I got the following message from Fiddler: 我必须说,我收到了Fiddler的以下消息:

Response is encoded and may need to be decoded before inspection. 在检查之前,对响应进行了编码,可能需要对其进行解码。 Click here to transform. 单击此处进行转换。

The screenshot is taken after I clicked to decode. 屏幕截图是在我单击解码后拍摄的。

But Angular is entering the error function of $http and Firefox tells me the response is empty: 但是Angular正在进入$http的错误功能,Firefox告诉我响应为空:

Firefox屏幕截图

The request headers sent from Angular tell my service it accepts application/json and plain/text (and */* ). 从Angular发送的请求标头告诉我的服务,它接受application/jsonplain/text (和*/* )。

So can anyone tell me why Fiddler is telling me there is a response, while Firefox and Angular tell me otherwise? 那么谁能告诉我为什么Fiddler告诉我有回应,而Firefox和Angular告诉我否则? Is it the decoding? 是解码吗? If so, I would expect I could add a function to my $http to transform the response. 如果是这样,我希望可以在$http添加一个函数来转换响应。 But in that function, I can see the data parameter is "" (an empty string). 但是在该函数中,我可以看到data参数为“”(空字符串)。

UPDATE UPDATE

I think the cause is the the response is sent in 'chunked' format. 我认为原因是响应是以“块状”格式发送的。 And Angular's $http can't handle chunked responses. Angular的$http无法处理分块的响应。 Now to find out why my server/Drupal is sending a chunked response for such a small response and how to avoid it. 现在找出为什么我的服务器/ Drupal发送如此小的响应的分块响应以及如何避免它。 Or how to accept chunked reponses in Angular. 或者如何在Angular中接受分块响应。

UPDATE 2 更新2

I've managed to put this behavior in a fiddle using jQuery. 我已经成功地把这种行为在拨弄使用jQuery。 The resource it's calling is unprotected, so my question has little to do with OAuth (I'll try to rewrite it later). 它所调用的资源未受保护,因此我的问题与OAuth无关(我将在以后尝试重写它)。 I'm not sure if it's the chunked response or CORS. 我不确定这是分块的响应还是CORS。

But via Fiddler, I can see I'm getting a response with all the data in it (the same data you see in your browser when you surf to the resource . Although you have to 'unchunk' it in Fiddler first. 但是,通过Fiddler,我可以看到我收到了包含所有数据的响应(浏览资源时您在浏览器中看到的数据相同。尽管您必须先在Fiddler中“解压缩”它)。

Or is my browser blocking it because of CORS, even though the response returns? 还是即使响应返回,我的浏览器还是因为CORS阻止了它?

If you hit F12 and look at your browser's error console, you will see: 如果按F12键并查看浏览器的错误控制台,您将看到:

XMLHttpRequest cannot load http://www.gentlesite.be/drupal/api/nodes. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://fiddle.jshell.net' is therefore not allowed access.

Same-Origin-Policy prevents your JavaScript from reading content from another site unless the other site explicitly opts-in. 除非其他站点明确选择加入,否则同源策略禁止您的JavaScript从另一个站点读取内容。 See this post for an introduction to Same-Origin-Policy. 请参阅此帖子以了解Same-Origin-Policy。

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

相关问题 谁能告诉我我的代码有什么问题? - Can anyone tell me what is wrong with my code? 谁能告诉我我的代码有什么问题 - Can anyone tell me what is wrong in my code 有人请告诉我$ .parseJSON有什么问题[javascript / jquery] - Someone please tell me what is wrong with my $.parseJSON [javascript / jquery] AngularJS否则函数会将我重定向到错误的路线 - AngularJS otherwise function redirects me to wrong route 我的 firebase 云 function 告诉我:Function 执行耗时 60004 毫秒,完成状态为“超时”,但为什么? 我的代码有什么问题:( - My firebase cloud function tells me: Function execution took 60004 ms, finished with status: 'timeout', but why? What is wrong with my code :( ajaxform 给我错误的回应 - ajaxform giving me wrong response 我的功能总是告诉我,我的问题出错了。 为什么? - My function will always tell me that I got my question wrong. Why? 有人可以告诉我我的代码有什么问题吗? 返回正确的世纪 - Can someone tell me what's wrong with my code? Return correct century 我的Jquery按钮-禁用/启用功能不起作用。 谁能告诉我怎么了? - My Jquery button- disable/enable function is not working. Can anyone tell me what's wrong? JavaScript:有人可以告诉我我的代码出了什么问题吗? - JavaScript: Can someone tell me what's going wrong with my code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM