如何在Rails中使用HTTParty gem时获取http头文件?

问题描述:

我正在使用gem'devise_token_auth'gem'httparty'如何在Rails中使用HTTParty gem时获取http头文件?

行动,我想从响应得到FF标题:

例子: HTTParty.post( “/ auth /中sign_in”,@options)

我需要:

access_token: response.headers['access-token'], 
client: response.headers['client'], 
expiry: response.headers['expiry'], 
token_type: response.headers['token-type'], 
uid: response.headers['uid'] 

请帮忙!

您可以访问头HTTParty返回这样:

require 'httparty' 

response = HTTParty.post("/auth/sign_in", @options) 

puts response.headers 

您还可以在这里看到一个例子:https://johnnunemaker.com/httparty/