这是返回的对象。我最终需要得到两件事:@token
和@expires_at
. 我怎么能从中得到它们?
@my_object = access_token(params[:provider])
然后输出:
#<OAuth2::AccessToken:0x007fd03df75db8
@client=#<OAuth2::Client:0x007fd035040ad0
@id="123xyz",
@secret="xyz123",
@site="https://graph.facebook.com",
@options={
:authorize_url=>"/oauth/authorize",
:token_url=>"oauth/access_token",
:token_method=>:post,
:connection_opts=>{
:ssl=>{
:ca_file=>"ca-bundle.crt"
}
},
:connection_build=>nil,
:max_redirects=>5,
:raise_errors=>true,
:mode=>:query,
:param_name=>"access_token",
:parse=>:query
},
@auth_code=#<OAuth2::Strategy::AuthCode:0x007fd035040c88
@client=#<OAuth2::Client:0x007fd035040ad0 ...>>,
@connection=#<Faraday::Connection:0x007fd037aec978
@headers={"User-Agent"=>"Faraday v0.8.7"},
@params={},
@options={},
@ssl={:ca_file=>"ca-bundle.crt"},
@parallel_manager=nil,
@default_parallel_manager=nil,
@builder=#<Faraday::Builder:0x007fd037aeca68
@handlers=[Faraday::Request::UrlEncoded, Faraday::Adapter::NetHttp]>,
@url_prefix=#<URI::HTTPS:0x007fd037aecf90 URL:https://graph.facebook.com/>,
@proxy=nil,
@app=#<Faraday::Request::UrlEncoded:0x007fd037aeb3c0
@app=#<Faraday::Adapter::NetHttp:0x007fd037aeb370
@app=#<Proc:0x007fd037aeb2a8@/gems/faraday-0.8.7/lib/faraday/connection.rb:87 (lambda)>>>>>,
@token="token_123",
@refresh_token=nil,
@expires_in=5149095,
@expires_at=1373851292,
@options={
:mode=>:query,
:header_format=>"Bearer %s",
:param_name=>"access_token"
},
@params={:token_url=>"oauth/access_token"}>