doorkeeper
Search…
Models
Starting from Doorkeeper 5.3 you can use your own model classes if you need to extend (or even override) default Doorkeeper models such as Application, AccessToken and AccessGrant.
By default Doorkeeper ActiveRecord ORM uses it's own classes:
1
# app/initializers/doorkeeper.rb
2
3
Doorkeeper.configure do
4
access_token_class "Doorkeeper::AccessToken"
5
access_grant_class "Doorkeeper::AccessGrant"
6
application_class "Doorkeeper::Application"
7
end
Copied!
If you're planning to use your own, don't forget inherit them from the base classes (listed above) or at least to include Doorkeeper ORM mixins into your custom models first:
  • ::Doorkeeper::Orm::ActiveRecord::Mixins::AccessToken - for access token
  • ::Doorkeeper::Orm::ActiveRecord::Mixins::AccessGrant - for access grant
  • ::Doorkeeper::Orm::ActiveRecord::Mixins::Application - for application (OAuth2 client)
An example of model customization:
1
Doorkeeper.configure do
2
access_token_class "MyAccessToken"
3
# ...
4
end
5
6
# app/models/my_access_token.rb
7
class MyAccessToken < ApplicationRecord
8
include ::Doorkeeper::Orm::ActiveRecord::Mixins::AccessToken
9
10
self.table_name = "hey_i_wanna_my_name"
11
12
def destroy_me!
13
destroy
14
end
15
end
Copied!
Copy link