Sha256: 9b49a4088825035570a6c18873c31ab8338dc3c935f82a1ee59bd3bf0808a22b
Contents?: true
Size: 829 Bytes
Versions: 1
Compression:
Stored size: 829 Bytes
Contents
require 'ostruct' class GoogleR::Token attr_accessor :issued_to, :audience, :scopes, :expires_at, :access_type, :token def initialize(token) self.token = token self.scopes = [] end def self.url "https://www.googleapis.com" end def self.api_headers {} end def path "/oauth2/v2/tokeninfo" end def self.from_json(json, *attrs) token = self.new(*attrs) token.issued_to = json["issued_to"] token.audience = json["audience"] token.scopes = json["scope"].split(" ") token.expires_at = Time.at(Time.now.to_i + json["expires_in"]) token.access_type = json["access_type"] token end def expires_in expires_at.to_i - Time.now.to_i end def to_google(yajl_opts = {}) Yajl::Encoder.encode({}, yajl_opts) end def new? self.token.nil? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
google_r-0.2.0 | lib/google_r/token.rb |