lperichon-contacts 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/contacts.gemspec +23 -0
- data/lib/contacts/windows_live.rb +19 -19
- data/lib/contacts.rb +2 -0
- metadata +3 -2
data/contacts.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{lperichon-contacts}
|
5
|
+
s.version = "1.0.3"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.date = %q{2010-07-12}
|
9
|
+
s.files = [".gitmodules", "LICENSE", "README.markdown", "Rakefile", "contacts.gemspec", "lib/contacts.rb", "lib/contacts/consumer.rb", "lib/contacts/google.rb", "lib/contacts/oauth_consumer.rb", "lib/contacts/util.rb", "lib/contacts/version.rb", "lib/contacts/windows_live.rb", "lib/contacts/yahoo.rb", "rails/init.rb", "spec/contact_spec.rb", "spec/feeds/contacts.yml", "spec/feeds/flickr/auth.getFrob.xml", "spec/feeds/flickr/auth.getToken.xml", "spec/feeds/google-many.xml", "spec/feeds/google-single.xml", "spec/feeds/wl_contacts.xml", "spec/feeds/yh_contacts.txt", "spec/feeds/yh_credential.xml", "spec/flickr/auth_spec.rb", "spec/gmail/auth_spec.rb", "spec/gmail/fetching_spec.rb", "spec/rcov.opts", "spec/spec.opts", "spec/spec_helper.rb", "spec/windows_live/windows_live_spec.rb", "spec/yahoo/yahoo_spec.rb"]
|
10
|
+
s.require_paths = ["lib"]
|
11
|
+
s.rubygems_version = %q{1.3.6}
|
12
|
+
s.summary = %q{Fetch users' contact lists without asking them to provide their passwords, as painlessly as possible.}
|
13
|
+
|
14
|
+
if s.respond_to? :specification_version then
|
15
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
16
|
+
s.specification_version = 3
|
17
|
+
|
18
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
19
|
+
else
|
20
|
+
end
|
21
|
+
else
|
22
|
+
end
|
23
|
+
end
|
@@ -46,7 +46,10 @@ module Contacts
|
|
46
46
|
#
|
47
47
|
configuration_attribute :force_origin
|
48
48
|
|
49
|
+
attr_accessor :wll
|
50
|
+
|
49
51
|
def initialize(options={})
|
52
|
+
self.wll = WindowsLiveLogin.new
|
50
53
|
@token_expires_at = nil
|
51
54
|
@location_id = nil
|
52
55
|
@delegation_token = nil
|
@@ -67,20 +70,12 @@ module Contacts
|
|
67
70
|
end
|
68
71
|
|
69
72
|
def authentication_url(target, options={})
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
query = {
|
77
|
-
'ps' => 'Contacts.View',
|
78
|
-
'ru' => target,
|
79
|
-
'pl' => privacy_policy_url,
|
80
|
-
'app' => app_verifier,
|
81
|
-
}
|
82
|
-
query['appctx'] = context if context
|
83
|
-
"#{url}?#{params_to_query(query)}"
|
73
|
+
wll.appid = self.application_id
|
74
|
+
wll.secret = self.secret_key
|
75
|
+
wll.securityalgorithm = 'wsignin1.0'
|
76
|
+
wll.policyurl = self.privacy_policy_url
|
77
|
+
wll.returnurl = target
|
78
|
+
wll.getConsentUrl('Contacts.Invite')
|
84
79
|
end
|
85
80
|
|
86
81
|
def forced_redirect_url(params)
|
@@ -107,9 +102,14 @@ module Contacts
|
|
107
102
|
end
|
108
103
|
|
109
104
|
def contacts(options={})
|
110
|
-
|
105
|
+
@wll.secret = self.secret_key
|
106
|
+
token = @wll.processConsentToken(options['ConsentToken'])
|
107
|
+
location_id = token.locationid
|
108
|
+
delegation_token = token.delegationtoken
|
109
|
+
token_expires_at = token.expiry
|
110
|
+
return nil if delegation_token.nil? || token_expires_at < Time.now
|
111
111
|
# TODO: Handle expired token.
|
112
|
-
xml = request_contacts
|
112
|
+
xml = request_contacts(location_id, delegation_token)
|
113
113
|
parse_xml(xml)
|
114
114
|
end
|
115
115
|
|
@@ -164,11 +164,11 @@ module Contacts
|
|
164
164
|
params
|
165
165
|
end
|
166
166
|
|
167
|
-
def request_contacts
|
167
|
+
def request_contacts(location_id, delegation_token)
|
168
168
|
http = Net::HTTP.new('livecontacts.services.live.com', 443)
|
169
169
|
http.use_ssl = true
|
170
|
-
url = "/users/@L@#{
|
171
|
-
authorization = "DelegatedToken dt=\"#{
|
170
|
+
url = "/users/@L@#{location_id}/rest/invitationsbyemail"
|
171
|
+
authorization = "DelegatedToken dt=\"#{delegation_token}\""
|
172
172
|
http.get(url, {"Authorization" => authorization}).body
|
173
173
|
end
|
174
174
|
|
data/lib/contacts.rb
CHANGED
@@ -82,4 +82,6 @@ module Contacts
|
|
82
82
|
autoload :Google, 'contacts/google'
|
83
83
|
autoload :Yahoo, 'contacts/yahoo'
|
84
84
|
autoload :WindowsLive, 'contacts/windows_live'
|
85
|
+
autoload :WindowsLiveLogin, 'contacts/windowslivelogin'
|
86
|
+
autoload :WindowsLiveLogin, 'contacts/windowslivelogin'
|
85
87
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
8
|
+
- 3
|
9
|
+
version: 1.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors: []
|
12
12
|
|
@@ -31,6 +31,7 @@ files:
|
|
31
31
|
- LICENSE
|
32
32
|
- README.markdown
|
33
33
|
- Rakefile
|
34
|
+
- contacts.gemspec
|
34
35
|
- lib/contacts.rb
|
35
36
|
- lib/contacts/consumer.rb
|
36
37
|
- lib/contacts/google.rb
|