Sha256: d837e16f522a63037b29a5d7f4c22a04bfedacbd98c969f695cd90288fdfa245
Contents?: true
Size: 968 Bytes
Versions: 1
Compression:
Stored size: 968 Bytes
Contents
require 'oauth/consumer' require 'mechanize' class Iknow::Auth attr_accessor :mode, :auth_token def initialize(options = {}) if options[:username] && options[:password] @mode = :basic_auth @auth_token = WWW::Mechanize.new @auth_token.auth(options[:username], options[:password]) elsif options[:token] && options[:secret] @mode = :oauth @auth_token = OAuth::AccessToken.new(Iknow::Auth.consumer, options[:token], options[:secret]) else raise ArgumentError.new('{:auth => "oauth_access_token", :secret => "oauth_access_token_secret"} or {:username "iknow_username", :password => "iknow_password"} is needed') end end def self.consumer @@consumer ||= OAuth::Consumer.new( Iknow::Config.oauth_consumer_key, Iknow::Config.oauth_consumer_secret, :site => Iknow::Config.iknow_api_base_url, :authorize_url => "#{Iknow::Config.iknow_base_url}/oauth/authorize" ) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
iknow-0.1.0 | lib/iknow/core/auth.rb |