我正在使用Mehanize,并希望对网站Twitter OAuth进行身份验证。
require 'mechanize'
agent = Mechanize.new
homepage = agent.get(HOME_URL)
auth = homepage.link_with(href: AUTH_URL)
form = auth.form_with(action: AUTH_ACTION)
uname = form.fields[2]
pword = form.fields[3]
uname.value = 'uname'
pword.value = 'pword'
loggedin = agent.submit(form, form.buttons.first)
结果是403异常:echanize::ResponseCodeError: 403 => Net::HTTPForbidden for https://api.twitter.com/oauth/authorize -- unhandled response
我找到并尝试了this article,它显示了如何处理异常,但没有运气登录。
有关如何使其发挥作用的任何见解?