Getting email back from Twitter Oauth with Devise and Rails - ruby-on-rails

I've set up a basic rails application to use twitter oauth gem and devise and have been able to log in a user. However, my problem is I've now got my app white-listed and I would like to get a user's email back in the response. I've followed all necessary steps on the twitter side (setting necessary permissions, URLS, and reset keys) and have tried passing both
include_email=true
and
include_email=email
as a params when I initiate the oauth sequence. I feel like I've read and re-read the docs and tried few edge cases I thought might work based off of very little I've found on-line.
Any help with this? Something I'm missing if you've done this before?

I solved my problem. The omniauth gem was not the latest version which would include email. In my gem file I needed to declare '~> 1.2.1' where I had version 1.2.0 - - the new version includes the following changes you can read about here: https://github.com/arunagw/omniauth-twitter/pull/96

Related

Ruby omniauth-ebay-oauth gem only getting user consent...not auth token

I had no problem getting omniauth-ebay-oauth (https://github.com/evilmartians/omniauth-ebay-oauth) working with Devise, but when Ebay hits the callback I've got a code, but I'd expect the gem to also exchange the code for an auth_token.
Is there something I'm missing with the gem? I don't see anything in the documentation that mentions swapping the code for an auth_token.
I can get the auth_token by doing an HTTP post in the controller, but it seems like a bit of a wasted usage of the gem.

Restforce Gem, Salesforce API retuning OAuth2::Error Missing_OAuth_Token

I've been attempting to get Ruby on Rails 4.1 to talk to our salesforce instance using the gem omniauth and gem restforce as per this instruction link here.
All seems to be going alright, I got things up and running, with a hyperlink that takes me to a salesforce login and seems to return to the callback correctly. However when it does i get the error:
OAuth2::Error
Missing_OAuth_Token
This leaves me really confused and mystified, my oauth token should surely be supplied by the callback?
I have my client_id and client_secret stored in the app and they appear to load in correctly. Adding my salesforce login and password through omniauth should provide all it needs right? I don't see anywhere else in the omniauth gem docs or restforce gem to stick an oauth token... and even then i'm not sure where i'd get it from.
I'd read that there had recently been some authentication failures with the gem omniauth and there is a current issue request to put out a new version. If I specify my gem to pull directly from the github. I get a similar bit distinct error that I have posted about here.
Could anyone give any advice on:
Where I should expect the missing Auth_Token to come from (I really can't work out if I'm supposed to be providing it in my app or if that's what comes back from salesforce
How would be best to go about debugging this? (i'd thought about using debugger but as it pings to code outside of my rails app i'm unsure how much help this would be.
What the correct way would be to go about setting this up properly!
Any help would be greatly appreciated!
This was actually a bug in the omniauth-salesforce gem - https://github.com/realdoug/omniauth-salesforce/pull/13.
There was a minor change to the way the Salesforce API worked which was resolved in the above pull request. You must have upgraded your gem which solved the problem.

Ruby on Rails 4 authentication, devise vs bcrypt

I am new to Ruby on Rails 4 and I started with the tutorial http://ruby.railstutorial.org/ruby-on-rails-tutorial-book and in this tutorial fo user's signup 'bcrypt' is used, however for my project I would like to have more options like email confirmation, password reset etc..So my question is, can I achieve all of this using existing rails 4 without any gems or do I need to use the 'devise' as suggested by some others in stack overflow. Also, can I use 'devise' gem along with 'bcrypt'?
Short answer: Devise isn't required. You can write all the authentication / email confirmation / password reset logic yourself. There's nothing inherently 'magical' about Devise, it's just a well-written solution to a common problem.
However...
Writing a complete (and secure) authentication system isn't an easy task. I'd recommend working through the tutorial and letting it guide you through writing your own authentication system there.
Then you'll be in a better position to understand how web app authentication works and whether or not to use Devise.
FYI, Devise already uses bcrypt, as seen on its gemspec:
s.add_dependency("bcrypt-ruby", "~> 3.0")

Implementing Open-id server with multiple provider

I want to implement an openid server which could interact with multiple providers to authenticate users. Basically I am looking for something like StackOverflow does for login.
I was looking into ruby-openid but it does not seem to be maintained with last commit 2-3 years back.
Can someone suggest me good gem /plugin or resource for implementing Open-id in Rails 3.2
Requirement :
Should be able to host my own open id server
Allow user to use multiple options like(google/ blogger / yahoo..etc)
Should work well with Rails 3.2 / ruby 1.9.3
There are a few useful gems:
OAuth
OmniAuth
P.S. ruby-openid is actially well maintained - last commit 18 days ago... ;)
You can include it in your application from it's Git Repository by adding this line into your Gemfile:
gem 'ruby-openid', :git => 'https://github.com/openid/ruby-openid.git'
Try OmniAuth
http://www.omniauth.org/
or you can also user RubyCAS Server
http://code.google.com/p/rubycas-server/
Try This OmniAuth and See Video you can easily Understand and implement
Part - 1 : http://railscasts.com/episodes/235-omniauth-part-1
Part - 2 : http://railscasts.com/episodes/236-omniauth-part-2

GitHub OAuth using Devise + OmniAuth

I've got an application at http://github.com/rails3book/ticketee that contains an OAuth portion provided by Devise. The configuration is at config/initializers/devise.rb. I have got this working with Twitter but always get this "invalid credentials" message back from GitHub.
I cannot see what I am doing differently between Twitter and GitHub. To my knowledge, this should Just Work(tm).
This is actually because GitHub's OAuth2 support doesn't mesh with the current draft of the OAuth2 specification. Basically, they want a parameter called "access_token" but the oauth2 gem's latest version (0.3.0 as of this writing) passes this through as "oauth_token", as the latest version of the draft requires.
This basically works with every other provider except GitHub because they haven't yet updated their support for this alternatively named parameter.
Did you register your application with Github? Do you provide the correct keys? I have a similar authentication here, without Devise, however, configuration (in development.rb) should be nearly the same: http://github.com/markusproske/omniauth_pure
Edit: you need different registrations for development and production due to the callback route.

Resources