class GoogleAuthClient

Public Class Methods

new(auth_token) click to toggle source
# File lib/google_auth_client.rb, line 3
def initialize(auth_token)
        @auth_token = auth_token
end

Public Instance Methods

data() click to toggle source
# File lib/google_auth_client.rb, line 7
def data
        @user_info = HTTParty.get(url,:headers => header)
        if @user_info.body.present?
                body = JSON.parse(@user_info.body)
                if body["error"].present?
                        error = body["error"]["errors"]
                        {:code => body["error"]["code"] , :error => error}
                else
                        {:code => 200, :data => body}
                end
        else
                {:code => 422 , :error => "Something went wrong"}
        end
end

Private Instance Methods

header() click to toggle source
# File lib/google_auth_client.rb, line 24
def header
        {"Authorization" => "OAuth #{@auth_token}"}
end
url() click to toggle source
# File lib/google_auth_client.rb, line 28
def url
        "https://www.googleapis.com/oauth2/v2/userinfo"
end