Skip to content
bonsaiben edited this page Jun 19, 2012 · 7 revisions

Welcome to the oauth-plugin wiki!

A few resources that you might find useful while developing with this plugin. All 3 links contain small fixes I had to make to get this plugin to work correctly.

An Omniauth strategy for a provider made with this plugin:

require 'omniauth/oauth'
require 'multi_json'
module OmniAuth
  module Strategies
    class Active < OAuth2
      def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
        client_options = {
          :site => 'http://localhost:3000',
          :authorize_path => '/oauth/authorize',
          :access_token_path => '/oauth/access_token'
        }

        super(app, :active, client_id, client_secret, client_options, options, &block)
      end

      protected
      
      # customize this to return data on the user who has just logged in.
      def user_data
        @data ||= MultiJson.decode(@access_token.get('/users/1.json'))['user']
      end

      def auth_hash
        OmniAuth::Utils.deep_merge(super, {
          'uid' => user_data['id'],
          'extra' => {'user_hash' => user_data}
        })
      end
  
    end
  end
end
Clone this wiki locally