Sha256: 7cde0489a9f3b0cfe99c20887bac7aac8030f6c9c7764aaf4b95369a8ef875ae

Contents?: true

Size: 760 Bytes

Versions: 9

Compression:

Stored size: 760 Bytes

Contents

# frozen_string_literal: true

module Doorkeeper
  module OAuth
    class ClientCredentialsRequest < BaseRequest
      class Creator
        def call(client, scopes, attributes = {})
          existing_token = existing_token_for(client, scopes)

          if Doorkeeper.configuration.reuse_access_token && existing_token&.reusable?
            return existing_token
          end

          existing_token&.revoke

          AccessToken.find_or_create_for(
            client, nil, scopes, attributes[:expires_in],
            attributes[:use_refresh_token]
          )
        end

        private

        def existing_token_for(client, scopes)
          Doorkeeper::AccessToken.matching_token_for client, nil, scopes
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
doorkeeper-5.2.6 lib/doorkeeper/oauth/client_credentials/creator.rb
doorkeeper-5.2.5 lib/doorkeeper/oauth/client_credentials/creator.rb
doorkeeper-5.2.4 lib/doorkeeper/oauth/client_credentials/creator.rb
doorkeeper-5.2.3 lib/doorkeeper/oauth/client_credentials/creator.rb
doorkeeper-5.2.2 lib/doorkeeper/oauth/client_credentials/creator.rb
doorkeeper-5.2.1 lib/doorkeeper/oauth/client_credentials/creator.rb
doorkeeper-5.2.0 lib/doorkeeper/oauth/client_credentials/creator.rb
doorkeeper-5.2.0.rc3 lib/doorkeeper/oauth/client_credentials/creator.rb
doorkeeper-5.2.0.rc2 lib/doorkeeper/oauth/client_credentials/creator.rb