Sha256: d02b734d47a40966938bb3442bef718d036f5570ceb716ea8783dcdcede660f8

Contents?: true

Size: 527 Bytes

Versions: 3

Compression:

Stored size: 527 Bytes

Contents

module OAuth
  class Google < OAuth::Base
    ACCESS_TOKEN_URL = 'https://accounts.google.com/o/oauth2/token'
    DATA_URL = 'https://www.googleapis.com/plus/v1/people/me/openIdConnect'

    def get_access_token
      response = @client.post(ACCESS_TOKEN_URL, @params.merge(grant_type: 'authorization_code'))
      
      JSON.parse(response.body)['access_token']
    end

    def get_names
      names = data[:name].try(:split).to_a

      [data[:given_name] || names.first, data[:family_name] || names.last]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pshq_engine-0.1.6 app/models/o_auth/google.rb
pshq_engine-0.1.5 app/models/o_auth/google.rb
pshq_engine-0.0.1 app/models/o_auth/google.rb