module Doorkeeper::AccessTokenMixin::ClassMethods

def create_for(application:, resource_owner:, scopes:, **token_attributes)

Returns:
  • (Doorkeeper::AccessToken) - new access token

Options Hash: (**token_attributes)
  • :use_refresh_token (Boolean) --
  • :expires_in (Integer) --

Parameters:
  • token_attributes (Hash) --
  • scopes (#to_s) --
  • resource_owner (ActiveRecord::Base, Integer) --
  • application (Doorkeeper::Application) --
def create_for(application:, resource_owner:, scopes:, **token_attributes)
  token_attributes[:application] = application
  token_attributes[:scopes] = scopes.to_s
  if Doorkeeper.config.polymorphic_resource_owner?
    token_attributes[:resource_owner] = resource_owner
  else
    token_attributes[:resource_owner_id] = resource_owner_id_for(resource_owner)
  end
  create!(token_attributes)
end