lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb
# Creates a not expired AccessToken record with a matching set of
# scopes that belongs to specific Application and Resource Owner.
#
# @param application [Doorkeeper::Application]
#   Application instance
# @param resource_owner [Mongoid::Document, Integer]
#   Resource Owner model instance or it's ID
# @param scopes [#to_s]
#   set of scopes (any object that responds to `#to_s`)
# @param token_attributes [Hash]
#   Additional attributes to use when creating a token
# @option token_attributes [Integer] :expires_in
#   token lifetime in seconds
# @option token_attributes [Boolean] :use_refresh_token
#   whether to use the refresh token
#
# @return [Doorkeeper::AccessToken] new access token
#
Creates a not expired AccessToken record with a matching set of
scopes that belongs to specific Application and Resource Owner.
Creates a not expired AccessToken record with a matching set of scopes that belongs to specific Application and Resource Owner .
def create_for(application:, resource_owner:, scopes:, **token_attributes)
            token_attributes[:application_id] = application&.id
            token_attributes[:scopes] = scopes.to_s
            if Doorkeeper.configuration.try(: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
def create_for ( application : , resource_owner : , scopes : , ** token_attributes ) token_attributes [ :application_id ] = application &. id token_attributes [ :scopes ] = scopes . to_s if Doorkeeper . configuration . try ( :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
Creates a not expired AccessToken record with a matching set of
scopes that belongs to specific Application and Resource Owner.
Creates a not expired AccessToken record with a matching set of scopes that belongs to specific Application and Resource Owner .
new access token
new access token
Doorkeeper::AccessToken
application
None
resource_owner
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 ` )
token_attributes
:use_refresh_token whether to use the refresh token
: use_refresh_token whether to use the refresh token