lib/doorkeeper/models/access_token_mixin.rb
# Looking for not expired AccessToken record with a matching set of
# scopes that belongs to specific Application and Resource Owner.
# If it doesn't exists - then creates it.
#
# @param application [Doorkeeper::Application]
#   Application instance
# @param resource_owner_id [ActiveRecord::Base, Integer]
#   Resource Owner model instance or it's ID
# @param scopes [#to_s]
#   set of scopes (any object that responds to `#to_s`)
# @param expires_in [Integer]
#   token lifetime in seconds
# @param use_refresh_token [Boolean]
#   whether to use the refresh token
#
# @return [Doorkeeper::AccessToken] existing record or a new one
#
Looking for not expired AccessToken record with a matching set of
scopes that belongs to specific Application and Resource Owner.
If it doesn't exists - then creates it.
Looking for not expired AccessToken record with a matching set of scopes that belongs to specific Application and Resource Owner . If it doesn ' t exists - then creates it .
def find_or_create_for(application, resource_owner_id, scopes, expires_in, use_refresh_token)
        if Doorkeeper.configuration.reuse_access_token
          access_token = matching_token_for(application, resource_owner_id, scopes)
          return access_token if access_token&.reusable?
        end
        create!(
          application_id: application.try(:id),
          resource_owner_id: resource_owner_id,
          scopes: scopes.to_s,
          expires_in: expires_in,
          use_refresh_token: use_refresh_token
        )
      end
def find_or_create_for ( application , resource_owner_id , scopes , expires_in , use_refresh_token ) if Doorkeeper . configuration . reuse_access_token access_token = matching_token_for ( application , resource_owner_id , scopes ) return access_token if access_token &. reusable? end create! ( application_id : application . try ( :id ) , resource_owner_id : resource_owner_id , scopes : scopes . to_s , expires_in : expires_in , use_refresh_token : use_refresh_token ) end
Looking for not expired AccessToken record with a matching set of
scopes that belongs to specific Application and Resource Owner.
Looking for not expired AccessToken record with a matching set of scopes that belongs to specific Application and Resource Owner .
existing record or a new one
existing record or a new one
Doorkeeper::AccessToken
application
None
resource_owner_id
Resource Owner model instance or it's ID
Resource Owner model instance or it ' s ID
scopes
set of scopes (any object that responds to `#to_s`)
set of scopes ( any object that responds to ` #to_s ` )
expires_in
token lifetime in seconds
token lifetime in seconds
use_refresh_token
whether to use the refresh token
whether to use the refresh token