class Gahh::Handler
Public Class Methods
new(options)
click to toggle source
# File lib/gahh/handler.rb, line 7 def initialize(options) @client_id = options[:client_id] @client_secret = options[:client_secret] @redirect_uri = options[:redirect_uri] end
testing_def(param)
click to toggle source
# File lib/gahh/handler.rb, line 3 def self.testing_def(param) puts "testing with parameter #{param}" end
Public Instance Methods
request_access_token(auth_code)
click to toggle source
# File lib/gahh/handler.rb, line 30 def request_access_token(auth_code) http = Net::HTTP.new('accounts.google.com', 443) path = '/o/oauth2/token' http.use_ssl = true data = "code=#{auth_code}&client_id=#{@client_id}&client_secret=#{@client_secret}&redirect_uri=#{@redirect_uri}&grant_type=authorization_code" response = http.post(path, data) values = JSON.parse(response.body) binding.pry end
retrieve_auth(scopes)
click to toggle source
# File lib/gahh/handler.rb, line 13 def retrieve_auth(scopes) # options expecting scopes organized in hash with api and expectation # ie {"analytics" => "read"} scope = Gahh::ApiScopeParser::convert_api_scope_to_uri(scopes) client = Signet::OAuth2::Client.new( :authorization_uri => 'https://accounts.google.com/o/oauth2/auth', :token_endpoint_uri => 'https://accounts.google.com/o/oauth2/token', :client_id => @client_id, :client_secret => @client_secret, :scope => scope, :redirect_uri => @redirect_uri ) return client.authorization_uri.to_s end