Class: OmniAuth::Strategies::Meetup

Inherits:
OAuth
  • Object
show all
Defined in:
lib/omniauth/strategies/meetup.rb

Overview

Authenticate with Meetup via OAuth and retrieve an access token for API usage

Usage:

use OmniAuth::Strategies::Meetup, 'consumerkey', 'consumersecret'

Instance Attribute Summary

Attributes inherited from OAuth

#consumer_key, #consumer_options, #consumer_secret, #name

Instance Method Summary collapse

Methods inherited from OAuth

#callback_phase, #consumer, #request_phase, #unique_id

Constructor Details

#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ Meetup

Initialize meetup middleware

Parameters:

  • app (Rack Application)

    standard middleware application parameter

  • consumer_key (String) (defaults to: nil)

    the application consumer id

  • consumer_secret (String) (defaults to: nil)

    the application consumer secret

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :sign_in (Boolean, true)

    When true, use a sign-in flow instead of the authorization flow.



19
20
21
22
23
24
25
26
# File 'lib/omniauth/strategies/meetup.rb', line 19

def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
  auth_path = (options[:sign_in] == false) ? 'http://www.meetup.com/authorize' : 'http://www.meetup.com/authenticate'

  super(app, :meetup, consumer_key, consumer_secret,
          { :request_token_path  => "https://api.meetup.com/oauth/request",
            :access_token_path   => "https://api.meetup.com/oauth/access",
            :authorize_path      => auth_path }, options)
end

Instance Method Details

#auth_hashObject



28
29
30
31
32
33
34
# File 'lib/omniauth/strategies/meetup.rb', line 28

def auth_hash
  OmniAuth::Utils.deep_merge(super, {
    'uid' => member['id'],
    'user_info' => ,
    'extra' => { 'user_hash' => member }
  })
end

#memberObject



47
48
49
# File 'lib/omniauth/strategies/meetup.rb', line 47

def member
  @member ||= parse(@access_token.get('https://api.meetup.com/members.json?relation=self').body)['results'][0]
end

#parse(response) ⇒ Object



51
52
53
# File 'lib/omniauth/strategies/meetup.rb', line 51

def parse(response)
  MultiJson.decode(response)
end

#user_infoObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/omniauth/strategies/meetup.rb', line 36

def 
  {
    'name' => member['name'],
    'image' => member['photo_url'],
    'location' => member['city'],
    'urls' => {
      'profile' => member['link']
    }
  }
end