Devise Oauth Twitter: OAuth::Unauthorized Forbidden 403
Asked Answered
P

4

5

I am trying to implement Oauth Twitter using Devise.
I have created app on twitter
I have set callback url to: http://localhost:3000
I have added this to config\initializers\devise.rb

  config.omniauth :twitter, "key", "key secret"

Sign in with Twitter automatically appears at this route: /users/sign_up/ But on clicking it I get this error

key and key secret are correct

I also tried deleting and creating new app.

I cannot get it fixed

Help would be greatly appreciated

enter image description here

Here it says that https needs to be setup. So I followed This to set it up. But getting the same error

Patrinapatriot answered 28/5, 2018 at 7:2 Comment(6)
if I am not wrong your callback url should be like this: http://www.example.com/users/auth/twitter/callback and you may want to mention the same in your twitter app settings.Sumptuary
Also forbidden usually means you are passing wrong credentials. this tutorial could help you figure out the missing part: sourcey.com/…Sumptuary
@Sumptuary Updated as you said in twitter app settings but didn't work outPatrinapatriot
I removed 'config.omniauth :twitter, "key", "key secret"' this line. Instead added to config/initializers/omniauth.rb and that error is gone. But now I am getting 'Not Found. Authentication passthru'Patrinapatriot
this question here should resolve the issue: #13813344Sumptuary
@Sumptuary Thanks for help. The issue was because of the configurations in twitter app settingsPatrinapatriot
P
7

Turns out that in twitter app settings Callback URL Lock was set to Yes by default. Switching it to No fixed the error.

Thanks to kubido for helping me out to close the issue on github

Patrinapatriot answered 29/5, 2018 at 6:33 Comment(0)
E
6

You can try to add these in the Callback URLs in https://apps.twitter.com/

Worked for me after almost an hour!

I got these URLs after failing the log-in. I checked the request_options. One way to do it is using BetterErrors gem.

enter image description here

Endoparasite answered 14/6, 2018 at 12:46 Comment(0)
E
4

I had been facing the same issue, eventually i fixed it by adding the following callbacks,

http://127.0.0.1:3000/auth/twitter/callback
http://127.0.0.1/
http://127.0.0.1/auth/twitter/callback
http://localhost:3000/auth/twitter/callback

and it worked like a charm, enter image description here

Endplay answered 20/6, 2018 at 19:36 Comment(0)
S
1

You need set the callback url to: "Your url"/auth/twitter/callback

Syndicate answered 15/12, 2019 at 11:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.