Module: Passport::Oauth::Context::ClassMethods

Defined in:
lib/passport/oauth/protocol/context.rb

Instance Method Summary collapse

Instance Method Details

#callback_url(options = {}) ⇒ Object



56
57
58
59
# File 'lib/passport/oauth/protocol/context.rb', line 56

def callback_url(options = {})
  #"http://localhost:4567"
  Rack::Context.request.url.split("?").first
end

#consumerObject

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



52
53
54
# File 'lib/passport/oauth/protocol/context.rb', line 52

def consumer
  token_class.consumer
end

#inspectObject



61
62
63
# File 'lib/passport/oauth/protocol/context.rb', line 61

def inspect
  "#<Passport::Oauth::Protocol @version='#{version}' @token='#{token.inspect}' @phase='#{phase}'>"
end

#phaseObject



36
37
38
39
40
# File 'lib/passport/oauth/protocol/context.rb', line 36

def phase
  return "request" if request?
  return "response" if response?
  return "none"
end

#providerObject



11
12
13
# File 'lib/passport/oauth/protocol/context.rb', line 11

def provider
  find(:oauth_provider)
end

#request_secretObject



32
33
34
# File 'lib/passport/oauth/protocol/context.rb', line 32

def request_secret
  version == 1.0 ? session_key(:oauth_request_token_secret) : params_key(:code)
end

#request_tokenObject



28
29
30
# File 'lib/passport/oauth/protocol/context.rb', line 28

def request_token
  version == 1.0 ? session_key(:oauth_request_token) : nil
end

#tokenObject

the token from the response parameters



24
25
26
# File 'lib/passport/oauth/protocol/context.rb', line 24

def token
  version == 1.0 ? params_key(:oauth_token) : params_key(:code)
end

#token_class(throw_error = true) ⇒ Object



15
16
17
# File 'lib/passport/oauth/protocol/context.rb', line 15

def token_class(throw_error = true)
  Passport.token(provider, throw_error)
end

#token_class?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/passport/oauth/protocol/context.rb', line 19

def token_class?
  token_class(false).blank?
end

#verifierObject



42
43
44
# File 'lib/passport/oauth/protocol/context.rb', line 42

def verifier
  params_key(:oauth_verifier)
end

#versionObject

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



47
48
49
# File 'lib/passport/oauth/protocol/context.rb', line 47

def version
  token_class.version
end