Module: AuthlogicConnect::Oauth::Variables

Includes:
State
Included in:
Process
Defined in:
lib/authlogic_connect/oauth/variables.rb

Instance Method Summary collapse

Methods included from State

#allow_oauth_redirect?, #authenticating_with_oauth?, #new_oauth_request?, #oauth_provider?, #oauth_request?, #oauth_response?, #redirecting_to_oauth_server?, #using_oauth?, #validate_password_with_oauth?

Instance Method Details

#oauth_consumerObject

the Oauth gem consumer, whereby we can make requests to the server



40
41
42
# File 'lib/authlogic_connect/oauth/variables.rb', line 40

def oauth_consumer
  token_class.consumer
end

#oauth_providerObject

this comes straight from either the params or session. it is required for most of the other accessors in here



12
13
14
# File 'lib/authlogic_connect/oauth/variables.rb', line 12

def oauth_provider
  from_session_or_params(:oauth_provider)
end

#oauth_responseObject

This should go…



24
25
26
# File 'lib/authlogic_connect/oauth/variables.rb', line 24

def oauth_response
  auth_params && oauth_token
end

#oauth_tokenObject

the token from the response parameters



29
30
31
32
# File 'lib/authlogic_connect/oauth/variables.rb', line 29

def oauth_token
  return nil unless token_class
  oauth_version == 1.0 ? auth_params[:oauth_token] : auth_params[:code]
end

#oauth_token_and_secretObject

this is a thick method. it gives you the final key and secret that we will store in the database



46
47
48
49
50
51
52
53
# File 'lib/authlogic_connect/oauth/variables.rb', line 46

def oauth_token_and_secret
  token_class.get_token_and_secret(
    :token          => auth_session[:oauth_request_token],
    :secret         => oauth_version == 1.0 ? auth_session[:oauth_request_token_secret] : oauth_token,
    :oauth_verifier => auth_params[:oauth_verifier],
    :redirect_uri   => auth_callback_url
  )
end

#oauth_variablesObject

this doesn’t do anything yet, just to show what variables we need from the form



6
7
8
# File 'lib/authlogic_connect/oauth/variables.rb', line 6

def oauth_variables
  [:oauth_provider]
end

#oauth_versionObject

the version of oauth we’re using. Accessed from the OauthToken subclass



35
36
37
# File 'lib/authlogic_connect/oauth/variables.rb', line 35

def oauth_version
  token_class.oauth_version
end

#token_classObject

next is “token_class”, which is found from the oauth_provider key. it is the OauthToken subclass, such as TwitterToken, which we use as the api for accessing oauth and saving the response to the database for a user.



19
20
21
# File 'lib/authlogic_connect/oauth/variables.rb', line 19

def token_class
  AuthlogicConnect.token(oauth_provider) unless oauth_provider.blank?
end