class Doorkeeper::OAuth::ClientCredentials::Issuer

Attributes

error[R]
token[R]
validator[R]

Public Class Methods

new(server, validator) click to toggle source
# File lib/doorkeeper/oauth/client_credentials/issuer.rb, line 9
def initialize(server, validator)
  @server = server
  @validator = validator
end

Public Instance Methods

create(client, scopes, attributes = {}, creator = Creator.new) click to toggle source
# File lib/doorkeeper/oauth/client_credentials/issuer.rb, line 14
def create(client, scopes, attributes = {}, creator = Creator.new)
  if validator.valid?
    @token = create_token(client, scopes, attributes, creator)
    @error = Errors::ServerError unless @token
  else
    @token = false
    @error = validator.error
  end

  @token
end

Private Instance Methods

create_token(client, scopes, attributes, creator) click to toggle source
# File lib/doorkeeper/oauth/client_credentials/issuer.rb, line 28
def create_token(client, scopes, attributes, creator)
  context = Authorization::Token.build_context(
    client,
    Doorkeeper::OAuth::CLIENT_CREDENTIALS,
    scopes,
    nil,
  )
  ttl = Authorization::Token.access_token_expires_in(@server, context)

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