Sometime, Google just don't work; you have to dive deep into the sample code.
The error I had is to send POST requests to douban
Signature does not match. Expected: xxxx
All the GET requests are working (obviously my tokens are correct), but not POST.
All search results are suggesting that douban doesn't implant the correct OAuth 1.0, but that's not the case!
There is one sentence in the manual
进行POST、PUT、DELETE请求时,豆瓣暂时不支持使用在url中或者post form中传递OAuth参数。因此你只能选择在header中传递OAuth参数。
It does emphasize to put authorization code in the header, but also indicates that douban doesn't support form
'Content-Type': 'application/x-www-form-urlencoded'
which is a default in python oauth2 library
The fix is easy, just indicate the Content-Type. There is no need to tweak the oauth2, nor to try to match it suggested basestring (that was what I did and was completely a waste of time, because I made perfect match basestring, but still no luck). Until...
headers = request.to_header()
headers['Content-Type'] = 'application/atom+xml; charset=utf-8'

![]()
Leave a Reply