Class: GRuby::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/g_ruby/auth.rb

Class Method Summary collapse

Class Method Details

.oauth2_url(state) ⇒ Object

GRuby::Auth.oauth2_url(state)



6
7
8
9
10
# File 'lib/g_ruby/auth.rb', line 6

def self.oauth2_url(state)
 a = "https://accounts.google.com/o/oauth2/auth?response_type=code&access_type=offline&approval_prompt=auto&client_id=#{GOOGLE_CLIENTID}&redirect_uri=#{GOOGLE_CALLBACK}&scope=https://www.googleapis.com/auth/analytics.readonly"
 a = a + "&state=#{state}"  if !state.blank?
 return a
end

.token(auth_code) ⇒ Object

GRuby::Auth.token(auth_code)



13
14
15
16
# File 'lib/g_ruby/auth.rb', line 13

def self.token(auth_code)
  g = Nestful.post "https://accounts.google.com/o/oauth2/token?method=POST&grant_type=authorization_code&code=#{auth_code}&client_id=#{GOOGLE_CLIENTID}&client_secret=#{GOOGLE_SECRET}&redirect_uri=#{GOOGLE_CALLBACK}"
  return GRuby::Util.get_json(g)
end