Hi Arron,
The “Malformed Authorization HTTP Header” message is only sent if there is
an Authorization header set but it’s format doesn’t match Bearer TOKEN or
OAuth TOKEN. A different message is sent if the Authorization header is
blank or if TOKEN has been extracted from the header but isn’t found in the
database.
Your code above looks fine - I don’t think you would see the Malformed
Authorization HTTP Header message even if self.accessToken was null. Could
it be that something else is modifying the header before it’s sent? Any
extra spaces added before or after the Bearer part would cause the
Malformed message to be sent.
I would suggest pointing your code at http://httpbin.org/ and see what
headers it’s actually sending.
Kind regards,
GraemeOn 14 November 2012 16:54, ArronKing arron.king@arrowdesign.co.uk wrote:
Hi
I’m having a few intermittent problems with a widget I’m building. It’s
using v2 of the API and the initial refresh token is generated by a web
application. However, I’ve hit a stumbling block and have tried everything
I can think of. The widget uses the refresh token to generate an access
token (which works ok), but then it calls v2/users/me - this is where I am
returned the error.I keep getting ‘Malformed Authorization HTTP Header’ errors back; it’s
worked a few times but I’ve not changed any code (hence the intermittence!).The token is fine as I am able to use the same one within CURL. I’m also
looking at the headers in generates and they seem to be fine;
‘Authorization: Bearer TOKEN’. As a debugging tool I’ve managed to run the
widget in several browsers and Google Chrome works fine - the request comes
back fine. But in Safari I get the ‘Malformed Authorization HTTP Header’;
which makes sense as the widgets run in Safari. But also adds to the
confusion as I would expect the browser to display the same behaviour.Here’s the ajax call exactly as it is in the widget (it’s using the
sandbox API and sendType = ‘GET’, sDataType = ‘json’):var ajaxSettings = { url: this.getApiUrl() + path, type: sendType, dataType: sDataType, success: onSuccess, error: onFail, headers: { 'Authorization': 'Bearer ' + self.accessToken, 'Content-Type': 'application/json', 'Accept': 'application/json' } }; $.ajax(ajaxSettings);
I guess my question is; is there anything obvious I’m doing wrong? Also
are you able to shed some light on the problem (perhaps from your end why
the error is being returned?)If you need any further information please let me know.
Thanks in advance
Arron
–
You received this message because you are subscribed to the Google Groups
“FreeAgent API” group.
To view this discussion on the web visit
https://groups.google.com/d/msg/freeagent_api/-/R-0Z1HNCulUJ.
To post to this group, send email to freeagent_api@googlegroups.com.
To unsubscribe from this group, send email to
freeagent_api+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/freeagent_api?hl=en.
Graeme Boyd
Senior Software Engineer
Web. freeagent.com http://www.freeagent.com/ Blog. The FreeAgent Blog - FreeAgent
Twitter. @freeagent https://twitter.com/#!/freeagent Facebook.
FreeAgent | Edinburgh
40 Torphichen Street, Edinburgh, EH3 8JB
FreeAgent Central Ltd. Registered in sunny Scotland SC316774