Class: Ikbis::Advanced::Base

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/ikbis/advanced/base.rb

Direct Known Subclasses

Media, Test, Upload

Defined Under Namespace

Classes: CouldNotLoadCredentials, CouldNotPost

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



11
12
13
# File 'lib/ikbis/advanced/base.rb', line 11

def access_token
  @access_token
end

Instance Method Details

#oauth_authentication(credential_file = 'credentials.yml') ⇒ Object

Authenticate using OAuth::Consumer. After calling this method, the user will be logged in in to ikbis and can use all the private methods.

Prerequisites:

Must call ikbis-auth to generate the credentials yaml file.


26
27
28
29
30
31
32
33
34
# File 'lib/ikbis/advanced/base.rb', line 26

def oauth_authentication(credential_file='credentials.yml')
  begin
    @credentials = YAML.load_file(credential_file)
  rescue
    raise CouldNotLoadCredentials, "Couldn't load your ikbis credentials. You may need to run ikbis-auth."
  end
  @consumer = OAuth::Consumer.new(@credentials[:consumer_key], @credentials[:consumer_secret], {:site => "http://localhost:3000"})
  @access_token = OAuth::AccessToken.new(@consumer, @credentials[:access_token], @credentials[:access_token_secret])
end