Module: Doorkeeper::AccessTokenMixin

Extended by:
ActiveSupport::Concern
Includes:
Models::Accessible, Models::Expirable, Models::Revocable, Models::Scopes, OAuth::Helpers
Included in:
AccessToken
Defined in:
lib/doorkeeper/models/access_token_mixin.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from Models::Scopes

#includes_scope?, #scopes, #scopes_string

Methods included from Models::Accessible

#accessible?

Methods included from Models::Revocable

#revoke, #revoked?

Methods included from Models::Expirable

#expired?, #expires_in_seconds

Instance Method Details

#acceptable?(scopes) ⇒ Boolean


120
121
122
# File 'lib/doorkeeper/models/access_token_mixin.rb', line 120

def acceptable?(scopes)
  accessible? && includes_scope?(*scopes)
end

#as_json(_options = {}) ⇒ Object


104
105
106
107
108
109
110
111
112
# File 'lib/doorkeeper/models/access_token_mixin.rb', line 104

def as_json(_options = {})
  {
    resource_owner_id:  resource_owner_id,
    scopes:             scopes,
    expires_in_seconds: expires_in_seconds,
    application:        { uid: application.try(:uid) },
    created_at:         created_at.to_i,
  }
end

#same_credential?(access_token) ⇒ Boolean

It indicates whether the tokens have the same credential


115
116
117
118
# File 'lib/doorkeeper/models/access_token_mixin.rb', line 115

def same_credential?(access_token)
  application_id == access_token.application_id &&
    resource_owner_id == access_token.resource_owner_id
end

#token_typeObject


96
97
98
# File 'lib/doorkeeper/models/access_token_mixin.rb', line 96

def token_type
  'bearer'
end

#use_refresh_token?Boolean


100
101
102
# File 'lib/doorkeeper/models/access_token_mixin.rb', line 100

def use_refresh_token?
  !!@use_refresh_token
end