class Oauthio::AccessToken
Attributes
oauth_token[R]
oauth_token_secret[R]
provider[R]
Public Class Methods
from_hash(client, hash)
click to toggle source
Initializes an AccessToken
from a Hash
@param [Client] the OAuth2::Client instance @param [Hash] a hash of AccessToken
property values @return [AccessToken] the initalized AccessToken
# File lib/oauthio/access_token.rb, line 11 def from_hash(client, hash) provider = hash.delete('provider') || hash.delete(:provider) access_token = hash.delete('access_token') || hash.delete(:access_token) oauth_token = hash.delete('oauth_token') || hash.delete(:oauth_token) oauth_token_secret = hash.delete('oauth_token_secret') || hash.delete(:oauth_token_secret) new(client, provider, access_token, oauth_token, oauth_token_secret, hash) end
new(client, provider, token, oauth_token, oauth_secret, opts={})
click to toggle source
Calls superclass method
# File lib/oauthio/access_token.rb, line 22 def initialize(client, provider, token, oauth_token, oauth_secret, opts={}) super client, token, opts @provider = provider @oauth_token = oauth_token.to_s @oauth_token_secret = oauth_secret.to_s end
Public Instance Methods
me()
click to toggle source
# File lib/oauthio/access_token.rb, line 29 def me k = @client.id # oauthv = 1 # TODO: Update this if !@token.empty? # oauthv=#{oauthv} oauthio_header = "k=#{k}&access_token=#{@token}" elsif !@oauth_token.empty? && !@oauth_token_secret.empty? # oauthv=#{oauthv} oauthio_header = "k=#{k}&oauth_token=#{@oauth_token}&" + "oauth_token_secret=#{@oauth_token_secret}" else # TODO: Throw error if no tokens found end opts = {:headers => {:oauthio => oauthio_header}} me_url = client.me_url(provider) request(:get, me_url, opts) end