I'm using the Omniauth Stripe-Connect gem and I'd like to add a scope, but the documentation does not cover this. Here's what I'm trying right now, but the scope and stripe-landing parameters are not being included:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :stripe_connect, ENV['STRIPE_CONNECT_CLIENT_ID'], ENV['STRIPE_SECRET'], { :scope => 'read_write', :stripe_landing => 'register' }
end
The gem/strategy: https://github.com/isaacsanders/omniauth-stripe-connect
With the above gem, adding scope and stripe_landing to the Builder does not work.
Instead use just this:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :stripe_connect, ENV['STRIPE_CONNECT_CLIENT_ID'], ENV['STRIPE_SECRET']
end
And then add in the parameters in your Omniauth link:
<a href='http://exampleapp.com/auth/stripe_connect?scope=read_write&stripe_landing=register'>Connect With Stripe</a>
Related
In my omniauth.rb
OmniAuth.config.logger = Rails.logger
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, Rails.application.secrets[:facebook_app_id], Rails.application.secrets[:facebook_secret], :scope => 'email,public_profile', :display => 'popup', :info_fields => 'email,public_profile'
end
Client side, javascript:
return FB.login(function(response) {
if (response.authResponse) {
return window.location = '/auth/facebook/callback;
}
}, {scope: 'email,public_profile'});
as per the FB API docs.
When the FB popup opens to ask for permissions, it correctly asks for email and public_profile. I hit OK and this is what request.env['omniauth.auth] provides me with only:
{"provider":"facebook","uid":"XXXXXXX","info":{"name":"XXXXXXX
XXXXXXX","image":"http://graph.facebook.com/XXXXXXX/picture"},"credentials":{"token":"XXXXXXX","expires_at":1444467600,"expires":true},"extra":{"raw_info":{"name":"XXXXXXX
XXXXXXX","id":"XXXXXXX"}}}
I see neither the email address nor any public info except the full name and the profile picture.
I have no clue what I'm doing wrong as I follow exactly the guidelines of the omniauth-facebook gem here: https://github.com/mkdynamic/omniauth-facebook and also the FB developer docs.
Any hints?
You are on the right path just need to update the info fields with the fields you want to pull from facebook, public_profile won't work
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, Rails.application.secrets[:facebook_app_id], Rails.application.secrets[:facebook_secret], :scope => 'email', :display => 'popup', :info_fields => 'email,first_name,last_name'
end
I am using the omniauth-magento gem: http://rubydoc.info/gems/omniauth-magento/0.0.6/frames
Setting my omniauth.rb file in initializers as such:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :magento, "TOKEN", "SECRET", :client_options => { :authorize_path => "/su", :site => "https://store.magento.com" }
end
The store needs to be dynamic though. How can I make it such OR how can I do the same thing in a controller?
Thanks!
I should mention there is another gem: https://github.com/Contiamo/omniauth-magento which allows to set dynamically but i have no clue where to put this.
I've got a rails 4 application with facebook authentication and I've deployed it on heroku.
Sometimes i debug my app using localhost. That's why I create two apps on facebook developers page - the first using heroku_address (app_id 1 and app_secret 1) and the second one using localhost_address (app_id 2 and app_secret 2).
My question is how should I configure my omniauth.rb so that my_rails_app will use app_id 1 set if heroku_adress or app_id 2 set if localhost. I would like my appliction_authentication to work both on localhost and on heroku_url without changing omniauth.rb.
Here is my omniauth.rb:
OmniAuth.config.logger = Rails.logger
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, '229517473864398', '88c42ceadf5ac4baeb36333a5fc990ac' #, {:client_options => {:ssl => {:ca_path => "/etc/ssl/certs"}}}
# provider :facebook, '1397526230476094', '5fd1171c4781525b9e5a873c095f4d6e' #, {:client_options => {:ssl => {:ca_path => "/etc/ssl/certs"}}}
end
end
Thanks in advance for your attention!
The best way is to put those information in ENV. It's easy to do with heroku, use the figaro gem if needed.
First, the context: I'm writing a little web app to do some custom Google Analytics reporting for me.
In my Gemfile:
gem 'omniauth'
gem 'omniauth-google-oauth2'
In my config/initializers/omniauth.rb:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :google_oauth2, ENV["GOOGLE_KEY"], ENV["GOOGLE_SECRET"]
{
:scope => "userinfo.email,userinfo.profile,analytics.readonly",
:approval_prompt => "auto"
}
end
When I get to the auth screen on google, it's only asking me for userinfo.email and userinfo.profile permissions, and nothing for analytics.readonly.
Looking at the URL when I'm auth'ing, I can see that it's only requesting the first two permissions. If I manually add the analytics permission, it grants the correct permissions. So, I've narrowed the issue down to
How I'm passing scope to the omniauth-google-oauth2 strategy, or
How the strategy is handling/ignoring the scope hash.
Also, I have double-checked that the Analytics API is turned on for my OAuth keys in the Google API Console.
Poorly formatted code, I was missing a comma after ENV["GOOGLE_SECRET"]. Below is the fixed code.
Rails.application.config.middleware.use OmniAuth::Builder do
provider :google_oauth2, ENV["GOOGLE_KEY"], ENV["GOOGLE_SECRET"],
{
:scope => "userinfo.email,userinfo.profile,analytics.readonly",
:approval_prompt => "auto"
}
end
I am facing the same issue as described here -
OmniAuth & Facebook: certificate verify failed
The most voted answer suggests adding the following to your Omniauth initializer:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, FACEBOOK_KEY, FACEBOOK_SECRET, {:client_options => {:ssl => {:ca_path => "/etc/ssl/certs"}}}
end
However he mentions "/etc/ssl/certs" is the CA_PATH for ubuntu.
What is the relevant CA_PATH for an windows ?
If there is no certificate on my machine , how do I install one and where do I put the certificate file ?
This is how I solved the issue -
I downloaded this file - http://certifie.com/ca-bundle/ca-bundle.crt.txt and put in my app/config folder.
I renamed the file as ca-bundle.crt
I updated my omniauth initializer to relfect the following -
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, FACEBOOK_KEY, FACEBOOK_SECRET, :client_options => { :ssl => { :ca_file => "#{Rails.root}/config/ca-bundle.crt" } }
end
And it worked.