class GoogleR::Token
Attributes
access_type[RW]
audience[RW]
expires_at[RW]
issued_to[RW]
scopes[RW]
token[RW]
Public Class Methods
api_headers()
click to toggle source
# File lib/google_r/token.rb, line 15 def self.api_headers {} end
from_json(json, *attrs)
click to toggle source
# File lib/google_r/token.rb, line 23 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
new(token)
click to toggle source
# File lib/google_r/token.rb, line 6 def initialize(token) self.token = token self.scopes = [] end
url()
click to toggle source
# File lib/google_r/token.rb, line 11 def self.url "https://www.googleapis.com" end
Public Instance Methods
expires_in()
click to toggle source
# File lib/google_r/token.rb, line 33 def expires_in expires_at.to_i - Time.now.to_i end
new?()
click to toggle source
# File lib/google_r/token.rb, line 41 def new? self.token.nil? end
path()
click to toggle source
# File lib/google_r/token.rb, line 19 def path "/oauth2/v2/tokeninfo" end
to_google(yajl_opts = {})
click to toggle source
# File lib/google_r/token.rb, line 37 def to_google(yajl_opts = {}) Yajl::Encoder.encode({}, yajl_opts) end