Sha256: 4b830f9ad2bd54691ac26b4d1a806e4e4ccb8ee01383bb39749f1922133eeba2
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
# https://console.developers.google.com # https://developers.google.com/identity/protocols/googlescopes class LuxOauth::Google < LuxOauth def scope [ 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile' ] end def format_response opts { email: opts['email'], name: opts['name'], avatar: opts['picture'], locale: opts['locale'], gender: opts['gender'] } end def login "https://accounts.google.com/o/oauth2/auth?client_id=#{@key}&redirect_uri=#{redirect_url}&scope=#{scope.join('%20')}&response_type=code" end def callback(session_code) result = RestClient.post('https://www.googleapis.com/oauth2/v3/token', { grant_type: 'authorization_code', client_id: @key, client_secret: @secret, code: session_code, redirect_uri: redirect_url }) hash = JSON.parse(result) user = JSON.parse RestClient.get('https://www.googleapis.com/oauth2/v1/userinfo', { :params => {:access_token => hash['access_token'], :alt=>:json }}) format_response user end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lux-fw-0.1.35 | ./lib/vendor/oauth/lib/google.rb |
lux-fw-0.1.17 | ./lib/vendor/oauth/lib/google.rb |