Class: Contacts::WindowsLive
Instance Attribute Summary collapse
Attributes inherited from Consumer
#error
Instance Method Summary
collapse
Methods inherited from Consumer
configuration, configuration_attribute, configure, deserialize, #serialize
Constructor Details
#initialize(options = {}) ⇒ WindowsLive
Returns a new instance of WindowsLive.
53
54
55
56
57
|
# File 'lib/contacts/windows_live.rb', line 53
def initialize(options={})
@token_expires_at = nil
@location_id = nil
@delegation_token = nil
end
|
Instance Attribute Details
#delegation_token ⇒ Object
Returns the value of attribute delegation_token.
51
52
53
|
# File 'lib/contacts/windows_live.rb', line 51
def delegation_token
@delegation_token
end
|
#token_expires_at ⇒ Object
Returns the value of attribute token_expires_at.
51
52
53
|
# File 'lib/contacts/windows_live.rb', line 51
def token_expires_at
@token_expires_at
end
|
Instance Method Details
#authentication_url(target = self.return_url, options = {}) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/contacts/windows_live.rb', line 73
def authentication_url(target=self.return_url, options={})
if force_origin
context = target
target = force_origin + URI.parse(target).path
end
url = "https://consent.live.com/Delegation.aspx"
query = {
'ps' => 'Contacts.Invite',
'ru' => target,
'pl' => privacy_policy_url,
'app' => app_verifier,
}
query['appctx'] = context if context
"#{url}?#{params_to_query(query)}"
end
|
#authorize(params) ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/contacts/windows_live.rb', line 95
def authorize(params)
consent_token_data = params['ConsentToken'] or
raise Error, "no ConsentToken from Windows Live"
eact = backwards_query_to_params(consent_token_data)['eact'] or
raise Error, "missing eact from Windows Live"
query = decode_eact(eact)
consent_authentic?(query) or
raise Error, "inauthentic Windows Live consent"
params = query_to_params(query)
@token_expires_at = Time.at(params['exp'].to_i)
@location_id = params['lid']
@delegation_token = params['delt']
true
rescue Error => error
@error = error.message
false
end
|
113
114
115
116
117
118
|
# File 'lib/contacts/windows_live.rb', line 113
def contacts(options={})
return nil if @delegation_token.nil? || @token_expires_at < Time.now
xml = request_contacts
parse_xml(xml)
end
|
#forced_redirect_url(params) ⇒ Object
90
91
92
93
|
# File 'lib/contacts/windows_live.rb', line 90
def forced_redirect_url(params)
target_origin = params['appctx'] and
"#{target_origin}?#{params_to_query(params)}"
end
|
#initialize_serialized(data) ⇒ Object
59
60
61
62
63
|
# File 'lib/contacts/windows_live.rb', line 59
def initialize_serialized(data)
@token_expires_at = Time.at(data['token_expires_at'].to_i)
@location_id = data['location_id']
@delegation_token = data['delegation_token']
end
|
#serializable_data ⇒ Object
65
66
67
68
69
70
71
|
# File 'lib/contacts/windows_live.rb', line 65
def serializable_data
data = {}
data['token_expires_at'] = @token_expires_at.to_i if @token_expires_at
data['location_id'] = @location_id if @location_id
data['delegation_token'] = @delegation_token if @delegation_token
data
end
|