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.



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

def consumer
  @consumer
end

#ns_aliasObject

Returns the value of attribute ns_alias.



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

def ns_alias
  @ns_alias
end

#ns_uriObject

Returns the value of attribute ns_uri.



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

def ns_uri
  @ns_uri
end

#scopeObject

Returns the value of attribute scope.



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

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.



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

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

Instance Method Details

#get_extension_argsObject



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

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

#parse_extension_args(args) ⇒ Object

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



45
46
47
48
# File 'lib/openid/extensions/oauth.rb', line 45

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