Class: Doorkeeper::OAuth::ClientCredentials::Creator

Inherits:
Object
  • Object
show all
Defined in:
lib/doorkeeper/oauth/client_credentials/creator.rb

Instance Method Summary collapse

Instance Method Details

#call(client, scopes, attributes = {}) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/doorkeeper/oauth/client_credentials/creator.rb', line 7

def call(client, scopes, attributes = {})
  existing_token = nil

  if lookup_existing_token?
    existing_token = find_existing_token_for(client, scopes)
    return existing_token if server_config.reuse_access_token && existing_token&.reusable?
  end

  with_revocation(existing_token: existing_token) do
    server_config.access_token_model.find_or_create_for(
      application: client,
      resource_owner: nil,
      scopes: scopes,
      **attributes,
    )
  end
end