title: How to create custom omniauth provider (how to return data)
body: <p>I searched all around the net, how to create a custom provider for omniauth.. and i succedded partly..</p>
  
  <p>I created a gem, and it worked perfectly, except the part, that i cant understand how to return the gathered data to sessions controller, like other providers do..</p>
  
  <p>here is the code in auth gem:</p>
  
  <pre><code>require 'multi_json'
  require 'digest/md5'
  require 'rest-client'
  
  module OmniAuth
    module Strategies
      class Providername &lt; OmniAuth::Strategies::OAuth
        attr_accessor :app_id, :api_key, :auth
  
        def initialize(app, app_id = nil, api_key = nil, options = {})
          super(app, :providername)
          @app_id = app_id
          @api_key = api_key
        end
  
        protected
  
        def request_phase
          redirect "http://valid_url"
        end
  
        def callback_phase
          if request.params['code'] &amp;&amp; request.params['status'] == 'ok'
            response = RestClient.get("http://valid_url2/?code=#{request.params['auth_code']}")
            auth = MultiJson.decode(response.to_s)
            unless auth['error']
              @auth_data = auth
  
              if @auth_data
                @return_data = OmniAuth::Utils.deep_merge(super, {
                    'uid' =&gt; @auth_data['uid'],
                    'nickname' =&gt; @auth_data['nick'],
                    'user_info' =&gt; {
                      'first_name' =&gt; @auth_data['name'],
                      'last_name' =&gt; @auth_data['surname'],
                      'location' =&gt; @auth_data['place'],
                    },
                    'credentials' =&gt; {
                      'apikey' =&gt; @auth_data['apikey']
                    },
                    'extra' =&gt; {'user_hash' =&gt; @auth_data}
                  })
              end
  
            end
          else
            fail!(:invalid_request)
          end
        rescue Exception =&gt; e
          fail!(:invalid_response, e)
        end
  
      end
    end
  end
  </code></pre>
  
  <p>and here i call it in my initializers:</p>
  
  <pre><code>Rails.application.config.middleware.use OmniAuth::Builder do
    provider "providername", Settings.providers.providername.app_id, Settings.providers.providername.app_secret
  end
  </code></pre>
  
  <p>in this code, everything works fine so far, the provider gets called, i get the info from provider, i create a hash (@auth_data) with info, but how do i return it</p>