Class: OmniAuth::Strategies::Meetup

Inherits:
OAuth
  • Object
show all
Defined in:
lib/omniauth/strategies/oauth/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.



16
17
18
19
20
21
22
23
24
# File 'lib/omniauth/strategies/oauth/meetup.rb', line 16

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'
  client_options = {
    :access_token_path => 'https://api.meetup.com/oauth/access',
    :authorize_path => auth_path,
    :request_token_path => 'https://api.meetup.com/oauth/request',
  }
  super(app, :meetup, consumer_key, consumer_secret, client_options, options, &block)
end

Instance Method Details

#auth_hashObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/omniauth/strategies/oauth/meetup.rb', line 26

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

#memberObject



49
50
51
# File 'lib/omniauth/strategies/oauth/meetup.rb', line 49

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

#parse(response) ⇒ Object



53
54
55
# File 'lib/omniauth/strategies/oauth/meetup.rb', line 53

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

#user_infoObject



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

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