简体   繁体   中英

Getting to the @consumer in OAuth hash

Trying to get the site in this oauth hash

authinfo = #<OmniAuth::AuthHash credentials=#<OmniAuth::AuthHash secret="0bh6vtu1kz00dw5twf1ojt4a1o6d0pb8" token="me4vyzf3zzp6shl9t7srclk2uvb2pomr"> extra=#<OmniAuth::AuthHash access_token=#<OAuth::AccessToken:0x007fbfb44f78a8 @token="me4vyzf3zzp6shl9t7srclk2uvb2pomr", @secret="0bh6vtu1kz00dw5twf1ojt4a1o6d0pb8", @consumer=#<OAuth::Consumer:0x007fbfb09332b8 @key="zlbz0tbpgexpxyrn342y5ccqkg0m8owc", @secret="10ad6du2udy5qh71j82xkhmf6pxb1zeh", @options={:signature_method=>"HMAC-SHA1", :request_token_path=>"/oauth/initiate", :authorize_path=>"/su", :access_token_path=>"/oauth/token", :proxy=>nil, :scheme=>:header, :http_method=>:post, :oauth_version=>"1.0", :site=>"https://store.windowfarms.com"}, @uri=#<URI::HTTPS:0x007fbfb44f7060 URL:https://store.windowfarms.com>, @http=#<Net::HTTP store.windowfarms.com:443 open=false>, @http_method=:post>, @params={:oauth_token=>"me4vyzf3zzp6shl9t7srclk2uvb2pomr", "oauth_token"=>"me4vyzf3zzp6shl9t7srclk2uvb2pomr", :oauth_token_secret=>"0bh6vtu1kz00dw5twf1ojt4a1o6d0pb8", "oauth_token_secret"=>"0bh6vtu1kz00dw5twf1ojt4a1o6d0pb8"}, @response=#<Net::HTTPInternalServerError 500 Internal Server Error readbody=true>>> info=#<OmniAuth::AuthHash::InfoHash email=nil first_name=nil last_name=nil> provider="magento" uid=0>

Tried this and no luck, got undefined [] for nil Class

auth_info["extra"]["access_token"]["consumer"]["options"]["site"]

Tried and failed.

auth_info["extra"]["access_token"]["@consumer"]["options"]["site"]

How can I get to @consumer -> @options

It looks like the access token is not a hash object and implements the consumer property as a reader method. It also looks like the consumer object exposes the options as a method as well. I would guess something like this should get you access:

auth_info["extra"]["access_token"].consumer.options["site"]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM