Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/models/social_auth/google_plus_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def name

def self.init_with(auth_token={})
access_token = fetch_access_token(auth_token)
access_token[:client_os] = auth_token[:client_os]
request = create_connection(access_token).get('me')

return create_with_request(
Expand Down Expand Up @@ -73,8 +74,9 @@ def self.fetch_access_token(auth_token={})
end

def self.create_connection(auth_token={})
GooglePlus.api_key = SocialAuth.google_api_key
GooglePlus.api_key = auth_token[:client_os] == "ANDROID" ? SocialAuth.google_android_api_key : SocialAuth.google_ios_api_key
GooglePlus.access_token = auth_token[:access_token]

GooglePlus::Person
end

Expand Down
16 changes: 8 additions & 8 deletions gemfiles/rails42.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ../
specs:
social_auth (0.0.12)
social_auth (0.0.13)
fb_graph2
google_plus (~> 0.2.3)
rails (~> 4.0)
Expand Down Expand Up @@ -79,7 +79,7 @@ GEM
multi_json
rack-oauth2 (>= 1.1)
url_safe_base64
ffi (1.9.8)
ffi (1.9.10)
globalid (0.3.3)
activesupport (>= 4.1.0)
google_plus (0.2.3)
Expand Down Expand Up @@ -170,12 +170,12 @@ GEM
rspec-support (~> 3.2.0)
rspec-support (3.2.2)
safe_yaml (1.0.4)
sidekiq (3.3.4)
celluloid (>= 0.16.0)
connection_pool (>= 2.1.1)
json
redis (>= 3.0.6)
redis-namespace (>= 1.3.1)
sidekiq (3.4.2)
celluloid (~> 0.16.0)
connection_pool (~> 2.2, >= 2.2.0)
json (~> 1.0)
redis (~> 3.2, >= 3.2.1)
redis-namespace (~> 1.5, >= 1.5.2)
simple_oauth (0.3.1)
slop (3.6.0)
sprockets (2.12.3)
Expand Down
6 changes: 6 additions & 0 deletions lib/social_auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ module SocialAuth
mattr_accessor :google_api_key
@@google_api_key = nil

mattr_accessor :google_android_api_key
@@google_api_key = nil

mattr_accessor :google_ios_api_key
@@google_api_key = nil

# Used to set up Social Login from the initializer.
def self.setup
yield self
Expand Down

Large diffs are not rendered by default.

48 changes: 25 additions & 23 deletions spec/fixtures/vcr_cassettes/google_plus_service/valid_request.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions spec/models/google_plus_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ module SocialAuth
@user = User.create(email: "email@address.com")
allow_any_instance_of(GooglePlusService).to receive(:redis_instance).and_return(Redis.new)
allow_any_instance_of(GooglePlusService).to receive(:append_to_associated_services).and_return(true)

SocialAuth.google_client_id = "1053743633063-aaearku9rl008rc8vq7muvreifc4jbo8.apps.googleusercontent.com"
SocialAuth.google_client_secret = "rK6Fkmo6qpiiy0_SnWJDOlgv"
SocialAuth.google_redirect_uri = "https://developers.google.com/oauthplayground"
SocialAuth.google_api_key = "AIzaSyAKMHRoLKyRo5rivF8hq_Ic3SmvphBYIBk"
SocialAuth.google_ios_api_key = "1053743633063-kf45rqjj2iqcgf1fmah8scico61knjfc.apps.googleusercontent.com"
end

describe "social login methods" do
Expand Down
5 changes: 3 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ def fb_access_token

def google_plus_access_token
{
auth_token: "4/81ovnVqwDmSnROuqAd9AfVu-0tZ7-ZdzQ-TVdpMAFTk.4gM5OPkuRu0TBrG_bnfDxpL07IdjmQI",
refresh_token: "1/b-cUt2E2hoExpHcu2MaglfxeG6aLzYH7ViSjWFhRGcR90RDknAdJa_sgfheVM0XT"
auth_token: "4/5kn069Y8UhqDJS46RRsl6bw63xLSuMmabN45s_0lo2Y",
refresh_token: "1/b-cUt2E2hoExpHcu2MaglfxeG6aLzYH7ViSjWFhRGcR90RDknAdJa_sgfheVM0XT",
client_os: "IOS"
}
end

Expand Down
1 change: 1 addition & 0 deletions spec/support/database.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
default: &default
adapter: postgresql
encoding: unicode
host: localhost
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
Expand Down