Class: OpenID::OAuth::Request

Inherits:
Extension show all
Defined in:
lib/openid/extensions/oauth.rb

Overview

An OAuth token request, sent from a relying party to a provider

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Extension

#to_message

Constructor Details

#initialize(consumer = nil, scope = nil) ⇒ Request

Returns a new instance of Request.



15
16
17
18
19
20
# File 'lib/openid/extensions/oauth.rb', line 15

def initialize(consumer = nil, scope = nil)
  @ns_alias = "oauth"
  @ns_uri = NS_URI
  @consumer = consumer
  @scope = scope
end

Instance Attribute Details

#consumerObject

Returns the value of attribute consumer.



13
14
15
# File 'lib/openid/extensions/oauth.rb', line 13

def consumer
  @consumer
end

#ns_aliasObject

Returns the value of attribute ns_alias.



13
14
15
# File 'lib/openid/extensions/oauth.rb', line 13

def ns_alias
  @ns_alias
end

#ns_uriObject

Returns the value of attribute ns_uri.



13
14
15
# File 'lib/openid/extensions/oauth.rb', line 13

def ns_uri
  @ns_uri
end

#scopeObject

Returns the value of attribute scope.



13
14
15
# File 'lib/openid/extensions/oauth.rb', line 13

def scope
  @scope
end

Class Method Details

.from_openid_request(oid_req) ⇒ Object

Instantiate a Request object from the arguments in a checkid_* OpenID message return nil if the extension was not requested.



32
33
34
35
36
37
38
39
# File 'lib/openid/extensions/oauth.rb', line 32

def self.from_openid_request(oid_req)
  oauth_req = new
  args = oid_req.message.get_args(NS_URI)
  return if args == {}

  oauth_req.parse_extension_args(args)
  oauth_req
end

Instance Method Details

#get_extension_argsObject



22
23
24
25
26
27
# File 'lib/openid/extensions/oauth.rb', line 22

def get_extension_args
  ns_args = {}
  ns_args["consumer"] = @consumer if @consumer
  ns_args["scope"] = @scope if @scope
  ns_args
end

#parse_extension_args(args) ⇒ Object

Set the state of this request to be that expressed in these OAuth arguments



43
44
45
46
# File 'lib/openid/extensions/oauth.rb', line 43

def parse_extension_args(args)
  @consumer = args["consumer"]
  @scope = args["scope"]
end