Class: Arkaan::OAuth::AccessToken
- Inherits:
-
Object
- Object
- Arkaan::OAuth::AccessToken
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/arkaan/oauth/access_token.rb
Overview
An access token is the value assigned to the application to access the data the user is allowed to access.
Instance Attribute Summary collapse
-
#authorization ⇒ Arkaan::OAuth::Authorization
The authorization code that issued this token to the application.
-
#expiration ⇒ Integer
The time, in seconds, after which the token is declared expired, and thus can’t be used.
-
#value ⇒ String
The value of the token, returned to the application when built.
Instance Method Summary collapse
-
#expired? ⇒ Boolean
Checks if the current date is inferior to the creation date + expiration period.
Instance Attribute Details
#authorization ⇒ Arkaan::OAuth::Authorization
Returns the authorization code that issued this token to the application.
21 |
# File 'lib/arkaan/oauth/access_token.rb', line 21 belongs_to :authorization, class_name: 'Arkaan::OAuth::Authorization', inverse_of: :tokens |
#expiration ⇒ Integer
Returns the time, in seconds, after which the token is declared expired, and thus can’t be used.
17 |
# File 'lib/arkaan/oauth/access_token.rb', line 17 field :expiration, type: Integer, default: 86_400 |
#value ⇒ String
Returns the value of the token, returned to the application when built.
14 |
# File 'lib/arkaan/oauth/access_token.rb', line 14 field :value, type: String, default: -> { SecureRandom.hex } |
Instance Method Details
#expired? ⇒ Boolean
Checks if the current date is inferior to the creation date + expiration period
29 30 31 |
# File 'lib/arkaan/oauth/access_token.rb', line 29 def expired? created_at.to_time.to_i + expiration < Time.now.to_i end |