我看到很多关于同一个问题的问题,但我找不到解决办法,所以我问了一个问题,以确保我没有错过任何事情。
在 Twitter 上,我将 callback_url 设置为“https://my_app_url/”。
# consumer
@consumer = OAuth::Consumer.new('consumer_id',
'secret_key',
:site => 'https://api.twitter.com')
# request_token
@request_token = @consumer.get_request_token(:oauth_callback => "https://my_app_url/?state=#{state}")
# then get the user to log in via
login_url = @request_token.authorize_url
# I have a params[:oauth_token] and params[:oauth_verifier] in return
# I don't know what the oauth token is for
# I then should be able to get an access token
# all oauth calls are done in an object so @request_token has been conserved.
@access_token = @request_token.get_access_token(:oauth_verifier => params[:oauth_verifier])
# then it happens.
# => 401 Unauthorized
我不知道为什么要提高 401。有没有我错过的步骤?我将不胜感激任何帮助。