I'm providing a "log in with twitter" link to /auth/twitter, which the omniauth gem handles.
On my development machine, this appears to work fine, redirecting to the twitter login page and returning to the callback set for the application at dev.twitter.com (http://127.0.0.1:3000/auth/twitter/callback).
I have a separate application registered for our test production server, with the only things different being the access token, secret, and callback. Accessing the /auth/twitter path on the production server results in
OAuth::Unauthorized (401 Unauthorized):
oauth (0.4.6) lib/oauth/consumer.rb:216:in `token_request'
oauth (0.4.6) lib/oauth/consumer.rb:136:in `get_request_token'
...
I've made sure that the server is indeed using my development key/secret by printing the ones used to the log as they are being set in /config/initializers/omniauth.rb. They match the ones given on the twitter page, and the callback registered is a valid address and points to the production server.
What could possibly be wrong here? Could this be a result of rate limiting?
Gemfile follows:
source 'https://rubygems.org'
gem 'rails', '3.2.3'
gem 'mysql2','0.3.11'
gem 'tweetstream'
gem 'koala'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'twitter-bootstrap-rails'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'twitter'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem 'thin'
/config/initializers/omniauth.rb:
puts "initializing twitter with #{TWITTER_KEY}, #{TWITTER_SECRET}"
Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, TWITTER_KEY, TWITTER_SECRET
provider :facebook, FACEBOOK_KEY, FACEBOOK_SECRET,
:scope => 'read_stream,publish_stream'
end
The server logs the correct key and secret on the first line here.
In my case, the problem was that the server time was about 50 minutes behind, and the requests were being rejected because the timestamp was too old.
Updating the system time fixed it.
don't forget to check the check-box in the twitter settings:
"Allow this application to be used to Sign in with Twitter"
Hope this helps someone
My solution was that you need to have a callback url specified in the Twitter.com Application Management section. https://apps.twitter.com/ This will let localhost urls work as well.
My problem was that I had checked "Callback Url locking". Just un-checked it at it worked.
Related
I am using the following gems in my application.
gem 'activerecord-session_store'
gem 'sidekiq'
gem 'sidekiq-unique-jobs'
gem 'sidekiq-cron'
gem 'sinatra', require: false
gem 'capistrano-sidekiq', github: 'seuros/capistrano-sidekiq'
I recently started using activerecord-session_store and in the process I remember having to update my secret_key_base for my application. Now when I try to make changes through the SideKiq admin panel I always get a blank white page that says "forbidden". I'm guessing that my session is not being shared correctly? How can I set up SideKiq to use the same secret_key_base as my application?
You can do the following to share Rails' secret key base with Sidekiq web interface:
Sidekiq::Web.set :session_secret, Rails.application.secrets[:secret_key_base]
I'm trying to add Google Login to my app using omniauth-google-oauth2 gem.
I have created the client Id and secret in console.developers.google.com and added redirect_uri as follows.
routes.rb
get 'auth/:provider/callback', to: 'people#socialmedialogin',:as => :callback
Gemfile
gem 'omniauth-oauth2', '~> 1.4.0'
gem "omniauth-google-oauth2"
I am facing the problem in signing in. It is authenticating with Google and fails to redirect. Error is as follows.
redirect_uri_mismatch: { "error" : "redirect_uri_mismatch" }
Extracted source (around line #113):
when 400..599
error = Error.new(response)
raise(error) if opts.fetch(:raise_errors, options[:raise_errors])
response.error = error
response
else
.....
Try to downgrade the gem (could be compatibility problem) :
gem 'omniauth-oauth2', '~> 1.3.1'
I am adding facebook authentication to my web app. Problem is that after I bundle installed the gems, it did not create this file.
config/initializers/omniauth.rb
Has anyone had this problem?
Gems:
#user authentication
gem 'devise'
gem 'opro'
gem 'omniauth'
gem 'omniauth-facebook'
gem 'oauth2'
It shouldn't be a problem. It doesn't create it automatically and you don't need to create it manually either as you seem to be using it in conjunction with devise. Instead, you can use the config.omniauth setting in your devise.rb initialiser. Have you read the relevant devise wiki page? https://github.com/plataformatec/devise/wiki/OmniAuth%3A-Overview
Also, note that you don't really need to specify omniauth and oauth2 in your Gemfile as they are dependencies of omniauth-facebook, so bundler should pull them in automatically.
So I created a rails app with the ability to sign up, receive a welcome email, sign up - reset the password (again receive an email) and be able to sign in with the option to remember the password. fully tested, both integration and back end tests.
Now I want to bring ember js into this so I added the following gems ...
gem 'ember-data-source', '>= 1.0.0.beta.3', '< 2.0'
gem 'emblem-rails', '~> 0.1'
gem 'ember-auth-rails', '~> 5.0'
gem 'ember-auth-request-jquery-rails', '~> 1.0'
gem 'ember-auth-response-json-rails', '~> 1.0'
gem 'ember-auth-strategy-token-rails', '~> 1.0'
gem 'ember-auth-session-cookie-rails', '~> 1.0'
gem 'ember-auth-module-ember_data-rails', '~> 1.0'
# for testing, in the testing section:
gem 'jasmine'
And then in my routes I went and did:
namespace :api do
namespace :v1 do
resource :users
end
end
And added the appropriate user contoller.
My question for you guys is:
I want to add ember to handle ALL the update, delete, create for users.
Ember for dealing with sessions and cookies.
Ember for allowing you to reset your password and receive welcome emails.
I have two sets of controllers, one for regular html - so your regular controller, and one under api/v1/users_controller.rb
What tutorials or steps are included to do this? I built everything from scratch instead of using devise ...
That's a mouthful of gems. Have you looked at this? http://coderberry.me/blog/2013/07/08/authentication-with-emberjs-part-1/
I'm following Rails Tutorial, creating a micoroposts app and pushing to Heroku. I'm able to get everything working locally, but the push to Heroku, I get no error messages, but the link myurl.heroku.com/micoroposts gives me the message, "The page you were looking for doesn't exist."
I have successfully added the following to my Gemfile (and run bundle install), per the tutorial advice, but no luck:
gem 'rails', '3.0.3'
'sqlite3-ruby', '1.3.2', :group => :development
Any ideas what might be happening?
You need to put the gem requirements on several lines:
gem 'rails', '3.0.3'
gem 'sqlite-ruby', '1.3.2'
And don't worry too much about the group => development, Heroku takes care of db connections for you.
When you did heroku create it would have told you an application name 'some-name-you-typed-in', so your url would be http://some-name-you-typed-in.heroku.com to see if the application starts.