Class: OpenID::OAuth::Response

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

Overview

A OAuth request token response, sent from a provider to a relying party

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Extension

#to_message

Constructor Details

#initialize(request_token = nil, scope = nil) ⇒ Response

Returns a new instance of Response.



56
57
58
59
60
61
# File 'lib/openid/extensions/oauth.rb', line 56

def initialize(request_token=nil, scope=nil)
  @ns_alias = 'oauth'
  @ns_uri = NS_URI
  @request_token = request_token
  @scope = scope
end

Instance Attribute Details

#request_tokenObject

Returns the value of attribute request_token.



55
56
57
# File 'lib/openid/extensions/oauth.rb', line 55

def request_token
  @request_token
end

#scopeObject

Returns the value of attribute scope.



55
56
57
# File 'lib/openid/extensions/oauth.rb', line 55

def scope
  @scope
end

Class Method Details

.from_success_response(success_response) ⇒ Object

Create a Response object from an OpenID::Consumer::SuccessResponse



64
65
66
67
68
69
70
# File 'lib/openid/extensions/oauth.rb', line 64

def self.from_success_response(success_response)
  args = success_response.get_signed_ns(NS_URI)
  return nil if args.nil?
  oauth_resp = new
  oauth_resp.parse_extension_args(args)
  return oauth_resp
end

Instance Method Details

#get_extension_argsObject



81
82
83
84
85
86
# File 'lib/openid/extensions/oauth.rb', line 81

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

#parse_extension_args(args, strict = false) ⇒ Object

parse the oauth request arguments into the internal state of this object if strict is specified, raise an exception when bad data is encountered



76
77
78
79
# File 'lib/openid/extensions/oauth.rb', line 76

def parse_extension_args(args, strict=false)
  @request_token = args["request_token"]
  @scope = args["scope"]
end