Sha256: f3c87295efbf539f2b127d6011ab2253d5b9c18fd3c0514a0a3b3a6ce26fe3b0

Contents?: true

Size: 1.08 KB

Versions: 18

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Doorkeeper
  module OAuth
    class ClientCredentialsRequest < BaseRequest
      class Issuer
        attr_accessor :token, :validation, :error

        def initialize(server, validation)
          @server = server
          @validation = validation
        end

        def create(client, scopes, creator = Creator.new)
          if validation.valid?
            @token = create_token(client, scopes, creator)
            @error = :server_error unless @token
          else
            @token = false
            @error = validation.error
          end
          @token
        end

        private

        def create_token(client, scopes, creator)
          context = Authorization::Token.build_context(
            client,
            Doorkeeper::OAuth::CLIENT_CREDENTIALS,
            scopes
          )
          ttl = Authorization::Token.access_token_expires_in(@server, context)

          creator.call(
            client,
            scopes,
            use_refresh_token: false,
            expires_in: ttl
          )
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
doorkeeper-5.1.2 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.2.6 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.0.3 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.1.1 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.2.5 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.2.4 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.2.3 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.2.2 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.2.1 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.2.0 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.2.0.rc3 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.2.0.rc2 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.2.0.rc1 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.1.0 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.1.0.rc2 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.1.0.rc1 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.0.2 lib/doorkeeper/oauth/client_credentials/issuer.rb
doorkeeper-5.0.1 lib/doorkeeper/oauth/client_credentials/issuer.rb