Sha256: 770a8b5f61bd1ded36961c3b92935baefda170096da756563a48de8b25e2bf9c
Contents?: true
Size: 1.9 KB
Versions: 3
Compression:
Stored size: 1.9 KB
Contents
require 'omniauth/oauth' require 'multi_json' module OmniAuth module Strategies # Authenticate with Meetup via OAuth and retrieve an access token for API usage # # Usage: # use OmniAuth::Strategies::Meetup, 'consumerkey', 'consumersecret' class Meetup < OmniAuth::Strategies::OAuth # Initialize meetup middleware # @param [Rack Application] app standard middleware application parameter # @param [String] consumer_key the application consumer id # @param [String] consumer_secret the application consumer secret # @option options [Boolean, true] :sign_in When true, use a sign-in flow instead of the authorization flow. 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 def auth_hash OmniAuth::Utils.deep_merge(super, { 'uid' => member['id'], 'user_info' => user_info, 'extra' => { 'user_hash' => member, }, } ) end def user_info { 'name' => member['name'], 'image' => member['photo_url'], 'location' => member['city'], 'urls' => { 'profile' => member['link'], }, } end def member @member ||= parse(@access_token.get('https://api.meetup.com/members.json?relation=self').body)['results'][0] end def parse(response) MultiJson.decode(response) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
oa-oauth-0.3.2 | lib/omniauth/strategies/oauth/meetup.rb |
oa-oauth-0.3.0 | lib/omniauth/strategies/oauth/meetup.rb |
oa-oauth-0.3.0.rc3 | lib/omniauth/strategies/oauth/meetup.rb |