Module: OAuth2::Provider::Models::AccessToken

Extended by:
ActiveSupport::Concern
Defined in:
lib/oauth2/provider/models/access_token.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#as_json(options = {}) ⇒ Object



20
21
22
23
24
# File 'lib/oauth2/provider/models/access_token.rb', line 20

def as_json(options = {})
  {"access_token" => access_token, "expires_in" => expires_in}.tap do |result|
    result["refresh_token"] = refresh_token if refresh_token.present?
  end
end

#initialize(*args, &block) ⇒ Object



14
15
16
17
18
# File 'lib/oauth2/provider/models/access_token.rb', line 14

def initialize(*args, &block)
  super
  self.access_token ||= self.class.unique_random_token(:access_token)
  self.refresh_token ||= self.class.unique_random_token(:refresh_token)
end

#refreshable?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/oauth2/provider/models/access_token.rb', line 26

def refreshable?
  refresh_token.present? && authorization.fresh?
end