Class: OAuth2::AuthResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/oauth20/auth_response.rb

Overview

Authorization code response. It contains all the important data to build response with new authorization code.

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ AuthResponse

Initialize new authorization response.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/oauth20/auth_response.rb', line 11

def initialize(request)
  @scope = request.scope
  @state = request.state
  @redirect_uri = request.redirect_uri
  
  @code = OAuth2::AuthCode.new({
    :user_id => request.user.email, 
    :client_key => request.client.key,
    :key => OAuth2::Utils.generate_key
  })
  
  @code.save
end

Instance Method Details

#to_urlObject

Get the redirect URI based on response attributes.



27
28
29
# File 'lib/oauth20/auth_response.rb', line 27

def to_url
  "#{@redirect_uri}?code=#{@code.key}&state=#{@state}&scope=#{@scope}"
end