class Bearer::AuthDetails::TokenData

Attributes

client_id[R]
expires_at[R]
issued_at[R]
scopes[R]
token_type[R]
value[R]

Public Class Methods

new(raw_data) click to toggle source
# File lib/bearer/auth_details.rb, line 28
def initialize(raw_data)
  expect_scopes = [
    TokenType::OAUTH2_ACCESS_TOKEN,
    TokenType::OAUTH2_REFRESH_TOKEN
  ].include?(raw_data[:token_type])

  @active = raw_data[:active]
  @client_id = raw_data[:client_id]
  @expires_at = raw_data[:exp] && Time.at(raw_data[:exp]).utc
  @issued_at = Time.at(raw_data[:iat]).utc
  @scopes =
    if raw_data[:scope]
      raw_data[:scope].split(" ")
    else
      expect_scopes ? [] : nil
    end
  @token_type = raw_data[:token_type]
  @value = raw_data[:value]
end

Public Instance Methods

active?() click to toggle source
# File lib/bearer/auth_details.rb, line 48
def active?
  @active
end