Module: FellowshipOneAPI::OAuth

Included in:
CredentialsAuthentication, OAuthAuthentication
Defined in:
lib/f1api/oauth.rb,
lib/f1api/oauth/oauth_authentication.rb,
lib/f1api/oauth/credentials_authentication.rb

Overview

Wrapper around the OAuth v1.0 specification using the oauth gem.

The Fellowship One API has two methods of authentication: [OAuthAuthentication] This is the default method if no method is declared. This method allows Fellowship Tech to handle the authentication and we redirect back to your app. [CredentialsAuthentication] The methods lets the consumer submit credentials and verify authentication.

Defined Under Namespace

Modules: CredentialsAuthentication, OAuthAuthentication

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authenticated_user_uriObject (readonly)

The URI for the resource of the authenticated user



30
31
32
# File 'lib/f1api/oauth.rb', line 30

def authenticated_user_uri
  @authenticated_user_uri
end

#oauth_access_tokenObject Also known as: access_token

The OAuth access token object where all requests are made off of



22
23
24
# File 'lib/f1api/oauth.rb', line 22

def oauth_access_token
  @oauth_access_token
end

#oauth_consumerObject (readonly) Also known as: consumer

The OAuth consumer object



26
27
28
# File 'lib/f1api/oauth.rb', line 26

def oauth_consumer
  @oauth_consumer
end

#oauth_consumer_keyObject Also known as: consumer_key

The OAuth consumer key. This will get set automatically from the YAML config file if not set explictly



11
12
13
# File 'lib/f1api/oauth.rb', line 11

def oauth_consumer_key
  @oauth_consumer_key
end

#oauth_consumer_secretObject Also known as: consumer_secret

The OAuth consumer secret. This will get set automatically from the YAML config file if not set explictly



17
18
19
# File 'lib/f1api/oauth.rb', line 17

def oauth_consumer_secret
  @oauth_consumer_secret
end

Instance Method Details

#load_consumer_config(type = :portal, site_url = nil) ⇒ Object

Creates the OAuth consumer object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/f1api/oauth.rb', line 33

def load_consumer_config(type = :portal, site_url = nil)
  case type
  when :portal
    authorize_path = FellowshipOneAPI::Configuration.portal_authorize_path
  when :weblink
    authorize_path = FellowshipOneAPI::Configuration.weblink_authorize_path
  end

  @oauth_consumer_key ||= FellowshipOneAPI::Configuration.consumer_key
  @oauth_consumer_secret ||= FellowshipOneAPI::Configuration.consumer_secret

  url = site_url.nil? ? FellowshipOneAPI::Configuration.site_url : site_url
  @oauth_consumer = ::OAuth::Consumer.new(@oauth_consumer_key,
                    @oauth_consumer_secret,
                    {:site => url,
                     :request_token_path => FellowshipOneAPI::Configuration.request_token_path,
                     :access_token_path => FellowshipOneAPI::Configuration.access_token_path,
                     :authorize_path => authorize_path })
end