class Doorkeeper::Config::Builder

Public Class Methods

new(&block) click to toggle source
# File lib/doorkeeper/config.rb, line 43
def initialize(&block)
  @config = Config.new
  instance_eval(&block)
end

Public Instance Methods

access_token_methods(*methods) click to toggle source

Change the way access token is authenticated from the request object. By default it retrieves first from the `HTTP_AUTHORIZATION` header, then falls back to the `:access_token` or `:bearer_token` params from the `params` object.

@param methods [Array] Define access token methods

# File lib/doorkeeper/config.rb, line 102
def access_token_methods(*methods)
  @config.instance_variable_set(:@access_token_methods, methods)
end
build() click to toggle source
# File lib/doorkeeper/config.rb, line 48
def build
  @config
end
client_credentials(*methods) click to toggle source

Change the way client credentials are retrieved from the request object. By default it retrieves first from the `HTTP_AUTHORIZATION` header, then falls back to the `:client_id` and `:client_secret` params from the `params` object.

@param methods [Array] Define client credentials

# File lib/doorkeeper/config.rb, line 92
def client_credentials(*methods)
  @config.instance_variable_set(:@client_credentials, methods)
end
confirm_application_owner() click to toggle source
# File lib/doorkeeper/config.rb, line 66
def confirm_application_owner
  @config.instance_variable_set(:@confirm_application_owner, true)
end
default_scopes(*scopes) click to toggle source

Define default access token scopes for your provider

@param scopes [Array] Default set of access (OAuth::Scopes.new) token scopes

# File lib/doorkeeper/config.rb, line 74
def default_scopes(*scopes)
  @config.instance_variable_set(:@default_scopes, OAuth::Scopes.from_array(scopes))
end
enable_application_owner(opts = {}) click to toggle source

Provide support for an owner to be assigned to each registered application (disabled by default) Optional parameter confirmation: true (default false) if you want to enforce ownership of a registered application

@param opts [Hash] the options to confirm if an application owner

is present

@option opts :confirmation (false)

Set confirm_application_owner variable
# File lib/doorkeeper/config.rb, line 61
def enable_application_owner(opts = {})
  @config.instance_variable_set(:@enable_application_owner, true)
  confirm_application_owner if opts[:confirmation].present? && opts[:confirmation]
end
optional_scopes(*scopes) click to toggle source

Define default access token scopes for your provider

@param scopes [Array] Optional set of access (OAuth::Scopes.new) token scopes

# File lib/doorkeeper/config.rb, line 82
def optional_scopes(*scopes)
  @config.instance_variable_set(:@optional_scopes, OAuth::Scopes.from_array(scopes))
end
reuse_access_token() click to toggle source

Reuse access token for the same resource owner within an application (disabled by default) Rationale: github.com/doorkeeper-gem/doorkeeper/issues/383

# File lib/doorkeeper/config.rb, line 114
def reuse_access_token
  @config.instance_variable_set(:@reuse_access_token, true)
end
use_refresh_token() click to toggle source

Issue access tokens with refresh token (disabled by default)

# File lib/doorkeeper/config.rb, line 107
def use_refresh_token
  @config.instance_variable_set(:@refresh_token_enabled, true)
end