Class: OmniAuth::Strategies::TypePad
- Defined in:
- lib/omniauth/strategies/type_pad.rb
Overview
Authenticate to Typepad via OAuth and retrieve basic user information.
Usage:
use OmniAuth::Strategies::Typepad, 'consumerkey', 'consumersecret', :application_id => 'my_type_pad_application_id'
application_id is required.
Instance Attribute Summary
Attributes inherited from OAuth
#consumer_key, #consumer_options, #consumer_secret, #name
Instance Method Summary collapse
- #auth_hash ⇒ Object
-
#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ TypePad
constructor
A new instance of TypePad.
- #user_hash ⇒ Object
- #user_info ⇒ Object
Methods inherited from OAuth
#callback_phase, #consumer, #request_phase, #unique_id
Constructor Details
#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ TypePad
Returns a new instance of TypePad.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/omniauth/strategies/type_pad.rb', line 17 def initialize(app, consumer_key = nil, consumer_secret = nil, = {}, &block) # TypePad uses the application ID for one of the OAuth paths. app_id = [:application_id] = { :site => 'https://www.typepad.com', :request_token_path => '/secure/services/oauth/request_token', :access_token_path => '/secure/services/oauth/access_token', :authorize_path => "/secure/services/api/#{app_id}/oauth-approve", :http_method => :get, # You *must* use query_string for the token dance. :scheme => :query_string } .merge! :scheme => :query_string, :http_method => :get super(app, :type_pad, consumer_key, consumer_secret, , ) end |
Instance Method Details
#auth_hash ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/omniauth/strategies/type_pad.rb', line 37 def auth_hash ui = user_info OmniAuth::Utils.deep_merge(super, { 'uid' => ui['uid'], 'user_info' => ui, 'extra' => {'user_hash' => user_hash} }) end |
#user_hash ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/omniauth/strategies/type_pad.rb', line 59 def user_hash # For authenticated requests, you have to use header as your scheme. # Failure to do so gives a unique response body - 'Auth is required'. # 'Unauthorized' is the response body of a truly unauthorized request. # Also note that API requests hit a different site than the OAuth dance. r = self.consumer.request( :get, "https://api.typepad.com/users/@self.json", @access_token, :scheme => 'header' ) @user_hash ||= MultiJson.decode(r.body) end |
#user_info ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/omniauth/strategies/type_pad.rb', line 46 def user_info user_hash = self.user_hash { 'uid' => user_hash['urlId'], 'nickname' => user_hash['preferredUsername'], 'name' => user_hash['displayName'], 'image' => user_hash['avatarLink']['url'], 'description' => user_hash['aboutMe'], 'urls' => {'Profile' => user_hash['profilePageUrl']} } end |