Class: Oauth::Contacts::Live
- Defined in:
- lib/oauth/contacts/live.rb
Constant Summary
Constants inherited from OAuth2
Instance Attribute Summary
Attributes inherited from OAuth2
Attributes inherited from Base
#access_token, #callback_url, #consumer
Instance Method Summary collapse
- #authorize_url ⇒ Object
- #contacts ⇒ Object
-
#initialize ⇒ Live
constructor
A new instance of Live.
Methods inherited from OAuth2
Constructor Details
#initialize ⇒ Live
Returns a new instance of Live.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/oauth/contacts/live.rb', line 10 def initialize super @callback_url = Settings.oauth.contacts.live.callback_url opts = { key: Settings.oauth.contacts.live.key, secret: Settings.oauth.contacts.live.secret, extra: { site: 'https://oauth.live.com', authorize_url: '/authorize', token_url: '/token', max_redirects: 5, raise_errors: true, token_method: :post, connection_opts: {} # [Hash] :connection_opts ({}) Hash of connection options to pass to initialize Faraday with } } @consumer = ::OAuth2::Client.new(opts[:key], opts[:secret], opts[:extra]) end |
Instance Method Details
#authorize_url ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/oauth/contacts/live.rb', line 27 def # Scopes and permissions http://msdn.microsoft.com/en-us/library/hh243646.aspx scopes = Settings.oauth.contacts.live.scopes extra_params = { scope: scopes.join(' '), redirect_uri: callback_url, response_type: 'code', state: 'live' } consumer.auth_code.( extra_params ) end |
#contacts ⇒ Object
40 41 42 43 44 45 |
# File 'lib/oauth/contacts/live.rb', line 40 def contacts token! request = 'https://apis.live.net/v5.0/me/contacts' @contacts = normalize(MultiJson.decode(access_token.get(request, parse: :json).body)) end |