Has anyone used omniauth with rails 2.3.8?

218 views
Skip to first unread message

Govind Naroji

unread,
Oct 31, 2010, 5:55:29 AM10/31/10
to omniauth
Hello All,

I am new to Rails and I am trying to use omniauth with rails 2.3.8. I
couldn't find any tutorial for this version of rails so I referred to
http://blog.railsrumble.com/blog/2010/10/08/intridea-omniauth.

I added the initializer as follows:
#omniauth.rb
OmniAuth::Strategies::Twitter = {
:consumer_key => 'xxxxxx',
:consumer_secret => 'xxxxxx'
}

After this step if I try to hit the URL '/auth/twitter' then I get "No
route matches "/auth/twitter" with {:method=>:get}".

Has anyone used omniauth with rails 2.3.8? Please help.

Thanks & Regards,
Govind Naroji

gordon

unread,
Oct 31, 2010, 5:09:06 PM10/31/10
to omniauth
I have it working successfully.

1) Had to use 0.1.15 version of omniauth
2) something like this in environment.rb (customise for your
situation)

config.gem 'omniauth'
config.middleware.use "OmniAuth::Builder" do
provider :twitter,
INSTANCE_CONFIG['twitter_consumer_key'],INSTANCE_CONFIG['twitter_consumer_secret']
provider :facebook, INSTANCE_CONFIG['facebook_app_id'],
INSTANCE_CONFIG['facebook_app_secret'], :scope =>
"publish_stream,user_likes,email,offline_access"
end

3) This for my routes

map.resources :authentications
#match '/auth/:provider/callback' => 'authentications#create'
map.auth '/auth/:provider/callback', :controller =>
'authentications', :action => 'create'

4) And basically followed the instructions in
http://railscasts.com/episodes/235-omniauth-part-1
http://railscasts.com/episodes/236-omniauth-part-2

with alterations as we use authlogic

Gordon

On Oct 31, 10:55 pm, Govind Naroji <govind.nar...@gmail.com> wrote:
> Hello All,
>
> I am new to Rails and I am trying to use omniauth with rails 2.3.8. I
> couldn't find any tutorial for this version of rails so I referred tohttp://blog.railsrumble.com/blog/2010/10/08/intridea-omniauth.

gordon

unread,
Oct 31, 2010, 5:14:14 PM10/31/10
to omniauth
Typo. Use version 0.1.5 of omniauth

On Nov 1, 10:09 am, gordon <gordon.kin...@gmail.com> wrote:
> I have it working successfully.
>
> 1) Had to use 0.1.15 version of omniauth
> 2) something like this in environment.rb (customise for your
> situation)
>
>   config.gem 'omniauth'
>   config.middleware.use "OmniAuth::Builder" do
>     provider :twitter,
> INSTANCE_CONFIG['twitter_consumer_key'],INSTANCE_CONFIG['twitter_consumer_secret']
>     provider :facebook, INSTANCE_CONFIG['facebook_app_id'],
> INSTANCE_CONFIG['facebook_app_secret'], :scope =>
> "publish_stream,user_likes,email,offline_access"
>   end
>
> 3) This for my routes
>
>   map.resources :authentications
>   #match '/auth/:provider/callback' => 'authentications#create'
>   map.auth '/auth/:provider/callback', :controller =>
> 'authentications', :action => 'create'
>
> 4) And basically followed the instructions inhttp://railscasts.com/episodes/235-omniauth-part-1http://railscasts.com/episodes/236-omniauth-part-2

madhums

unread,
Nov 17, 2010, 5:33:14 AM11/17/10
to omniauth
Here is a working demo https://github.com/madhums/omniauth-authlogic-demo
for rails 2.3.8. This is with authlogic.



On Nov 1, 2:14 am, gordon <gordon.kin...@gmail.com> wrote:
> Typo. Use version 0.1.5 of omniauth
>
> On Nov 1, 10:09 am, gordon <gordon.kin...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I have it working successfully.
>
> > 1) Had to use 0.1.15 version of omniauth
> > 2) something like this in environment.rb (customise for your
> > situation)
>
> >   config.gem 'omniauth'
> >   config.middleware.use "OmniAuth::Builder" do
> >     provider :twitter,
> > INSTANCE_CONFIG['twitter_consumer_key'],INSTANCE_CONFIG['twitter_consumer_s ecret']
> >     provider :facebook, INSTANCE_CONFIG['facebook_app_id'],
> > INSTANCE_CONFIG['facebook_app_secret'], :scope =>
> > "publish_stream,user_likes,email,offline_access"
> >   end
>
> > 3) This for my routes
>
> >   map.resources :authentications
> >   #match '/auth/:provider/callback' => 'authentications#create'
> >   map.auth '/auth/:provider/callback', :controller =>
> > 'authentications', :action => 'create'
>
> > 4) And basically followed the instructions inhttp://railscasts.com/episodes/235-omniauth-part-1http://railscasts.c...
>
> > with alterations as we useauthlogic

szimek

unread,
Nov 23, 2010, 4:03:15 PM11/23/10
to omniauth
If you don't want to clutter you environment.rb file you can also put
the following code into config/initializers/omniauth.rb:

ActionController::Dispatcher.middleware.use OmniAuth::Builder do
provider :twitter, "KEY", "SECRET"
end

This is just for Rails 2.3 of course.

On Oct 31, 10:09 pm, gordon <gordon.kin...@gmail.com> wrote:
> I have it working successfully.
>
> 1) Had to use 0.1.15 version of omniauth
> 2) something like this in environment.rb (customise for your
> situation)
>
>   config.gem 'omniauth'
>   config.middleware.use "OmniAuth::Builder" do
>     provider :twitter,
> INSTANCE_CONFIG['twitter_consumer_key'],INSTANCE_CONFIG['twitter_consumer_s ecret']
>     provider :facebook, INSTANCE_CONFIG['facebook_app_id'],
> INSTANCE_CONFIG['facebook_app_secret'], :scope =>
> "publish_stream,user_likes,email,offline_access"
>   end
>
> 3) This for my routes
>
>   map.resources :authentications
>   #match '/auth/:provider/callback' => 'authentications#create'
>   map.auth '/auth/:provider/callback', :controller =>
> 'authentications', :action => 'create'
>
> 4) And basically followed the instructions inhttp://railscasts.com/episodes/235-omniauth-part-1http://railscasts.com/episodes/236-omniauth-part-2
Reply all
Reply to author
Forward
0 new messages