Sha256: a14e073369e89d2a3d86ac4a701e54cf67e190d6f2db1832ed0fd1bda01db8b7

Contents?: true

Size: 777 Bytes

Versions: 7

Compression:

Stored size: 777 Bytes

Contents

require 'oauth2'
class Oauth2Token < ConsumerToken
  
  def self.consumer
    @consumer||=create_consumer
  end 
  
  def self.create_consumer(options={})
    @consumer||=OAuth2::Client.new credentials[:key],credentials[:secret],credentials[:options]
  end
    
  def self.authorize_url(callback_url)
    options = {:redirect_uri=>callback_url}
    options[:scope] = credentials[:scope] if credentials[:scope].present?
    consumer.web_server.authorize_url(options)
  end
  
  def self.access_token(user, code, redirect_uri)
    access_token = consumer.web_server.get_access_token(code, :redirect_uri => redirect_uri)
    find_or_create_from_access_token user, access_token
  end
  
  def client
    @client ||= OAuth2::AccessToken.new self.class.consumer, token
  end
    
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
oauth-plugin-0.4.0.rc2 lib/oauth/models/consumers/services/oauth2_token.rb
oauth-plugin-0.4.0.rc1 lib/oauth/models/consumers/services/oauth2_token.rb
oauth-plugin-0.4.0.pre7 lib/oauth/models/consumers/services/oauth2_token.rb
oauth-plugin-0.4.0.pre6 lib/oauth/models/consumers/services/oauth2_token.rb
oauth-plugin-0.4.0.pre5 lib/oauth/models/consumers/services/oauth2_token.rb
insrc-oauth-plugin-0.4.0.pre6 lib/oauth/models/consumers/services/oauth2_token.rb
insrc-oauth-plugin-0.4.0.pre5 lib/oauth/models/consumers/services/oauth2_token.rb