Class: Oauth::Contacts::Google
- Defined in:
- lib/oauth/contacts/google.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 ⇒ Google
constructor
A new instance of Google.
Methods inherited from OAuth2
Constructor Details
#initialize ⇒ Google
Returns a new instance of Google.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/oauth/contacts/google.rb', line 9 def initialize super @callback_url = Settings.oauth.contacts.google.callback_url opts = { key: Settings.oauth.contacts.google.key, secret: Settings.oauth.contacts.google.secret, extra: { site: 'https://accounts.google.com', authorize_url: '/o/oauth2/auth', token_url: '/o/oauth2/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
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/oauth/contacts/google.rb', line 26 def scopes = Settings.oauth.contacts.google.scopes extra_params = { scope: scopes.join(' '), redirect_uri: callback_url, response_type: 'code', access_type: 'offline', approval_prompt: 'force', state: 'google' } consumer.auth_code.( extra_params ) end |
#contacts ⇒ Object
40 41 42 43 44 45 |
# File 'lib/oauth/contacts/google.rb', line 40 def contacts token! request = "https://www.google.com/m8/feeds/contacts/default/full?alt=json" @contacts = normalize(access_token.get(request, :parse => :json).parsed) end |