I have a very strange problem, but only at production server.
I was using this Gem in my Gemfile.
gem "omniauth-facebook", "~> 1.4.1"
But suddenly started getting the following error on production, works fine at local.
heroku[router]: at=info method=GET path=/auth/failure?message=invalid_credentials&strategy=facebook host=www.myapp.com fwd="182.189.55.111" dyno=web.1 queue=0 wait=0ms connect=1ms service=90ms status=302 bytes=95
Searched around different forums and people says, a temporary solution is just to revert back to 1.4.0 version i.e.
gem "omniauth-facebook", "1.4.0"
It also works fine at local but started getting another error message at production.
OmniAuth::Strategies::Facebook::NoAuthorizationCodeError (must pass either a `code` parameter or a signed request (via `signed_request` parameter or a `fbsr_XXX` cookie)):
this link says to upgrade again to this version 1.4.1
Seems to a be deadlock/looping situation here. Can anybody faced/fixed this issue?
Thanks in advance.
I assume you are using the JS SDK to login? Maybe your code looks something like:
if (response.authResponse) {
var url = "/auth/facebook/callback";
window.location = url;
}
I'm not sure why the signed request isn't being passed along automatically, but I've found this workaround to work fine:
if (response.authResponse) {
var url = "/auth/facebook/callback";
url += '&' + $.param({ signed_request: response.authResponse.signedRequest });
window.location = url;
}
Related
Things were working fine until I started the upgrade from Rails 4.2 to 5.0
Using qbo_api gem (1.8.1) which also now needs the simple_oauth (0.3.1) as well as the oauth (0.5.4) gem. (The faraday gem (0.14.0) is loaded as another dependency.)
I can successfully do get requests for invoice, customer, etc., so the keys and initialization of the qbo_api object are all working for qbo_api.get() but when I try to create an invoice with qbo_api.create(:invoice, payload: ...), I get the error:
Operation Could not find resource for relative : /v3/company/123145710499109/invoice of full path: https://sandbox.qbo.intuit.com/qbo50/v3/company/123145710499109/invoice is not supported.
The same qbo_api object is working for get, I see nothing obviously wrong with the URL, and it is unreleated to the JSON payload. I'm not sure where to look to debug this problem.
BTW, clicking on the URL above seems to go to QB just fine, returning a validation error as you would expect.
This turns out to be a problem in the 1.8.0 and 1.8.1 versions of the qbo_api gem. Minimul has released version 1.8.2 which fixes this problem.
Kudos to Minimul for a quick response to this.
check your realmId. Most probably realmId is not match to your connected intuit app. This is why its tells that Operation Could not find resource for relative.
I have a Rails app (3.2.12) that I wanted to add locale switching via HTTP Accept-Language header.
What I did to achieve that:
I added rack-contrib to my Gemfile:
gem 'rack-contrib', require: 'rack/contrib'
ran bundle install, added the middleware to my config/application.rb:
config.middleware.use Rack::Locale
and inspect the request env my controller:
puts request.env.keys.select{|v| v=~/rack/ }
The spec I run is a controller spec, it has render_views in it.
My problem:
There's no rack.locale key in the request environment. I double-checked rake middlware, it lists Rack::Locale toward the end, right before run MyApp::Application.routes.
After some debugging I found out that the middleware is never called when I run
rspec spec/controllers/authentication_controller_spec.rb
BUT: Running the same code in script/rails s thin gives me more keys in the request env, namely:
rack.request.cookie_string
rack.locale
rack.request.query_string
rack.request.query_hash
So, I guess the question is: Why does RSpec refuse to pick up a Rack middleware?
Controller specs do not go through the stack, they pretty much call directly on the controller itself. You'll probably want to use Rspec's request type tests for this.
My app worked a few days ago.
I have switched to 'thin' from webrick
now I get
2011-12-28T07:08:53+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets/jquery.livequery-6725741b06c676d9173d5056b277caeb.js"):
I saw on other question that they were told to set this to true
config.serve_static_assets = false
but heroku recommends against that.
I have tried both using rake assets:precompile locally and then pushing and also without it and let heroku precompile.
Both give same error
How do I make sure the javascripts are served, compiled and available?
Why is the error occuring?
I'm using rails 3.1.3 on cedar, Latest Thin.
I was able to solve this using the question Rails 3.1 asset precompilation - include all javascript files
so.. problem solved
I have a Rails app running on 3.1.0.rc5, and I've setup omniauth for twitter exactly the same as seen here (https://github.com/sferik/sign-in-with-twitter) but it's still not working.
The problem is that after Twitter is redirecting back to my callback URL I have request.env["omniauth.auth"] is nil, rack.auth is nil too. I even went so far as to print out the entire request.env hash and didn't see anything like access_token or access_secret.
The only thing that doesn't look like my request token and secret is stored in action_dispatch.secret_token.
Any ideas on how to make this work?
Ok, so I got this working now. My Gemfile was:
gem "oa-oauth", :require => "omniauth/oauth"
gem "twitter"
I changed it to:
gem 'omniauth', :git => 'git://github.com/intridea/omniauth.git'
gem 'twitter'
gem 'json_pure'
gem 'json'
And everything started working. The request.env["omniauth.auth"] key was present etc. I had to add the json gem lines because of a uninitialized constant JSON::ParserError error I was getting. I think that is a bug in the release candidate.
Hi
I know this question have been asked before but the answers there isn't working for me.
I still get the, when redirecting back to my site.
/auth/failure?message=invalid_response
I have ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0] installed, using rails 3.0.7 and the required gems installed. I read on another thread that you should have pure_json added to the gemfile to make it work. But that didn't help me either.
I'm clueless... Thanks in advance
authenticationscontroller
def index
#authentications = current_user.authentications if current_user
end
def create
#render :text => request.env["omniauth.auth"].to_yaml
auth = request.env["omniauth.auth"]
current_user.authentications.find_or_create_by_provider_and_uid(auth['provider'], auth['uid'])
flash[:notice] = "Authentication successful."
redirect_to authentications_url
end
I was able to get this to work by specifying the following in my Gemfile
gem 'omniauth', '0.2.0'
Version 0.2.6 wouldn't work for me. I also updated by .rvmrc to rvm use 1.9.2#rails3. Oh, also make sure you're logged in - do note that in your code above you are assuming that current_user exists. See Ryan's Railscast part two for allowing user creation via Omniauth.
I've got a demo working here, but do note I'm doing authentication from scratch rather than using Devise.