Sha256: 6881a63238f90068fec957592bf332edb1d291ef9cc4d8cdc33c41c65d69ca21
Contents?: true
Size: 1.27 KB
Versions: 6
Compression:
Stored size: 1.27 KB
Contents
require 'omniauth/strategies/oauth2' module OmniAuth module Strategies class GoogleOauth2 include OmniAuth::Strategy option :client_options, { :site => 'https://accounts.google.com', :authorize_url => '/o/oauth2/auth', :token_url => '/o/oauth2/token' } def request_phase google_email_scope = "www.googleapis.com/auth/userinfo.email" options[:scope] ||= "https://#{google_email_scope}" options[:scope] << " https://#{google_email_scope}" unless options[:scope] =~ %r[http[s]?:\/\/#{google_email_scope}] redirect client.auth_code.authorize_url( {:redirect_uri => callback_url, :response_type => "code"}.merge(options)) end def auth_hash OmniAuth::Utils.deep_merge(super, { 'uid' => info['uid'], 'info' => info, 'credentials' => {'expires_at' => @access_token.expires_at}, 'extra' => {'user_hash' => user_data} }) end info do { 'email' => "TESTING EMAIL", 'uid' => "TESTING UID", 'name' => "TESTING NAME" } end def user_data @data ||= @access_token.get("https://www.googleapis.com/userinfo/email?alt=json").parsed end end end end
Version data entries
6 entries across 6 versions & 1 rubygems