开发者

URL encoding for Python OAuth2

开发者 https://www.devze.com 2023-02-19 20:02 出处:网络
I am using %20 to encode a url using oauth2 for python. It does no开发者_如何学Got seem to work.I see that it encodes %20 as %252B . Is there a way around?

I am using %20 to encode a url using oauth2 for python.

It does no开发者_如何学Got seem to work. I see that it encodes %20 as %252B . Is there a way around?

Edited with example

import oauth2 as oauth
client = oauth.Client(consumer)
url = 'http://localhost:8080/api/v1/search?Name=Julian'
method= 'GET'
response,content = client.request(url,method)
print content

The above code works. If I try

Name=Julian%20Assange or 
Name=Julian+Assange, 

it does not work. The %20 is encoded to %252B


This could be a double quoting issue.

urllib2.quote('%')
'%25'

Can you try not encoding your url before giving it to oauth?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号