Sha256: 357f3bb8c8b693a4508f5b349c9eb281192f469166f4101df3451ef44dbb1360

Contents?: true

Size: 1015 Bytes

Versions: 4

Compression:

Stored size: 1015 Bytes

Contents

module Doorkeeper
  module OAuth
    class CodeResponse
      include OAuth::Authorization::URIBuilder
      include OAuth::Helpers

      attr_accessor :pre_auth, :auth, :response_on_fragment

      def initialize(pre_auth, auth, options = {})
        @pre_auth = pre_auth
        @auth = auth
        @response_on_fragment = options[:response_on_fragment]
      end

      def redirectable?
        true
      end

      def redirect_uri
        if URIChecker.native_uri? pre_auth.redirect_uri
          auth.native_redirect
        elsif response_on_fragment
          uri_with_fragment(
            pre_auth.redirect_uri,
            access_token: auth.token.token,
            token_type: auth.token.token_type,
            expires_in: auth.token.expires_in_seconds,
            state: pre_auth.state
          )
        else
          uri_with_query pre_auth.redirect_uri,
                         code: auth.token.token,
                         state: pre_auth.state
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
doorkeeper-4.2.0 lib/doorkeeper/oauth/code_response.rb
doorkeeper-4.1.0 lib/doorkeeper/oauth/code_response.rb
doorkeeper-4.0.0 lib/doorkeeper/oauth/code_response.rb
doorkeeper-4.0.0.rc4 lib/doorkeeper/oauth/code_response.rb