Permalink
Browse files

gmail_access_token

  • Loading branch information...
1 parent 11738f3 commit ada7fc1cf934186b5e1bd5dec3411c1194004973 @kentosasa kentosasa committed Mar 12, 2014
Showing with 6 additions and 6 deletions.
  1. +6 −6 lib/omnicontacts/importer/gmail.rb
@@ -29,7 +29,7 @@ def fetch_contacts_using_access_token access_token, token_type
def fetch_current_user access_token, token_type
self_response = https_get(@self_host, @profile_path, contacts_req_params, contacts_req_headers(access_token, token_type))
- user = current_user self_response
+ user = current_user(self_response, access_token, token_type)
set_current_user user
end
@@ -50,7 +50,7 @@ def contacts_from_response response_as_json
return contacts if response.nil?
response['feed']['entry'].each do |entry|
# creating nil fields to keep the fields consistent across other networks
-
+
contact = { :id => nil,
:first_name => nil,
:last_name => nil,
@@ -94,7 +94,7 @@ def contacts_from_response response_as_json
contact[:relation] = entry['gContact$relation'].first['rel']
end
end
-
+
address = entry['gd$structuredPostalAddress'][0] if entry['gd$structuredPostalAddress']
if address
contact[:address_1] = address['gd$street']['$t'] if address['gd$street']
@@ -118,11 +118,12 @@ def contacts_from_response response_as_json
contacts
end
- def current_user me
+ def current_user me, access_token, token_type
return nil if me.nil?
me = JSON.parse(me)
user = {:id => me['id'], :email => me['email'], :name => me['name'], :first_name => me['given_name'],
- :last_name => me['family_name'], :gender => me['gender'], :birthday => birthday(me['birthday']), :profile_picture => me['picture']
+ :last_name => me['family_name'], :gender => me['gender'], :birthday => birthday(me['birthday']), :profile_picture => me['picture'],
+ :access_token => access_token, :token_type => token_type
}
user
end
@@ -133,7 +134,6 @@ def birthday dob
return birthday_format(birthday[2], birthday[3], nil) if birthday.size == 4
return birthday_format(birthday[1], birthday[2], birthday[0]) if birthday.size == 3
end
-
end
end
end

0 comments on commit ada7fc1

Please sign in to comment.