Class: HiuAuth

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

Class Method Summary collapse

Class Method Details

.verify_google_credential(id_token) ⇒ Object

Verify google id token from google credential response Arguments:

id_token: (String)

Output: [is_success(boolean), data(Hash)]



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/hiu_auth.rb', line 10

def self.verify_google_credential(id_token)
  base_url = 'https://www.googleapis.com'
  uri = "/oauth2/v3/tokeninfo?id_token=#{id_token}"
  headers = { 'Content-Type': 'application/json' }
  request = HiuHttp.new(base_url, uri, :get, headers)
  response = request.call
  if response.status == 200
    data = JSON.parse(response.body)
    return [true, data]
  end
  [false]
end