我对 oauth 完全陌生,我正在尝试获取用户关注的博客列表。
这产生的授权链接将我链接到提示用户拒绝或允许访问的页面(如果我手动将链接粘贴到浏览器中。)。它重定向到以 oauth_verifier=xxxx 结尾的 url。我将其复制到命令行中。
但是,我在第 95 行收到错误 400。
任何帮助是极大的赞赏!
69 import oauth2 as oauth
70 import urlparse
71
72 url = "http://www.tumblr.com/oauth"
73 request_token_url = '%s/request_token' % url
74 authorize_url = '%s/authorize/' % url
75 access_token_url = '%s/access_token/' % url
76
77 consumer = oauth.Consumer(key=oauth_key,secret=oauth_secret)
78 client = oauth.Client(consumer)
79 response, content = client.request(request_token_url, 'GET')
80 if response['status'] != '200':
81 raise Exception('Invalid response: %s' % response['status'])
82
83 request_token = dict(urlparse.parse_qsl(content))
84 authorize_link = '%s?oauth_token=%s' %
85 print "Go to: " , authorize_link,"\n"
86 oauth_verifier = raw_input("What is the oauth_verifier?")
87
88 token = oauth.Token(request_token['oauth_token'], request_token['oauth_token_secret'])
89 token.set_verifier(oauth_verifier)
90 client = oauth.Client(consumer, token)
91
92 print "token: ",token,"\n"
93 response, content = client.request(access_token_url, "POST")
94
95 if response['status']!='200':
96 raise Exception('Invalid response %s' %response['status'])
97
(authorize_url,request_token['oauth_token'])