class Doorkeeper::OAuth::CodeResponse

Attributes

auth[R]
pre_auth[R]
response_on_fragment[R]

Public Class Methods

new(pre_auth, auth, options = {}) click to toggle source
# File lib/doorkeeper/oauth/code_response.rb, line 10
def initialize(pre_auth, auth, options = {})
  @pre_auth = pre_auth
  @auth = auth
  @response_on_fragment = options[:response_on_fragment]
end

Public Instance Methods

body() click to toggle source
# File lib/doorkeeper/oauth/code_response.rb, line 24
def body
  if auth.try(:access_token?)
    {
      access_token: auth.token.plaintext_token,
      token_type: auth.token.token_type,
      expires_in: auth.token.expires_in_seconds,
      state: pre_auth.state,
    }
  elsif auth.try(:access_grant?)
    {
      code: auth.token.plaintext_token,
      state: pre_auth.state,
    }
  end
end
issued_token() click to toggle source
# File lib/doorkeeper/oauth/code_response.rb, line 20
def issued_token
  auth.token
end
redirect_uri() click to toggle source
# File lib/doorkeeper/oauth/code_response.rb, line 40
def redirect_uri
  if URIChecker.oob_uri?(pre_auth.redirect_uri)
    auth.oob_redirect
  elsif response_on_fragment
    Authorization::URIBuilder.uri_with_fragment(pre_auth.redirect_uri, body)
  else
    Authorization::URIBuilder.uri_with_query(pre_auth.redirect_uri, body)
  end
end
redirectable?() click to toggle source
# File lib/doorkeeper/oauth/code_response.rb, line 16
def redirectable?
  true
end