Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting an argument error when trying to use omniauth #174

Closed
edwardvalentini opened this issue Mar 9, 2015 · 6 comments · Fixed by #250
Closed

getting an argument error when trying to use omniauth #174

edwardvalentini opened this issue Mar 9, 2015 · 6 comments · Fixed by #250

Comments

@edwardvalentini
Copy link

ArgumentError in DeviseTokenAuth::OmniauthCallbacksController#redirect_callbacks

wrong number of arguments (1 for 0)

# pull resource class from omniauth return
def resource_class
  if omniauth_params
    omniauth_params['resource_class'].constantize
  end

Application Trace | Framework Trace | Full Trace
devise_token_auth (0.1.32.beta6) app/controllers/devise_token_auth/omniauth_callbacks_controller.rb:105:in resource_class' devise_token_auth (0.1.32.beta6) app/controllers/devise_token_auth/concerns/set_user_by_token.rb:19:inset_user_by_token'

it seems like the set_user_by_token method is calling resource_class with an argument but it is not supposed to take an argument..

it also looks like omniauth_callbacks_controller.rb is supposed to skip the set_user_by_token callback but it doesnt seem to be doing so...

I also had this exact problem with 0.1.31...

Any ideas?

@greywolfz
Copy link

I am facing the exact same problem. I can overcome it by commenting our my own def resource_class.

@lynndylanhurley
Copy link
Owner

@greywolfz - is this still an issue with the latest beta?

@greywolfz
Copy link

I am running with

  • devise (3.4.1)
  • devise_token_auth (0.1.32.beta8)
  • omniauth (1.2.2)
  • omniauth-facebook (2.0.1)
  • omniauth-github (1.1.2)
  • omniauth-google-oauth2 (0.2.6)
  • omniauth-oauth2 (1.2.0)

My omniauth providers are defined in /initializers/omniauth.rb

in ``controllers/api/vi/base_controller.rb` I am overriding the resources_class

        def resource_class
          @resource_class ||= resource_name.classify.constantize
        end

The following error is returned:

wrong number of arguments (1 for 0)

If I comment out the definition authorization works, but other parts of my app do not.

@anggiaj
Copy link

anggiaj commented Apr 24, 2015

ArgumentError at /v1/documents/1.json

wrong number of arguments (1 for 0)

activesupport (4.1.8) lib/active_support/core_ext/class/attribute.rb, line 106

  101           val
  102         end
  103   
  104         if instance_reader
  105           remove_possible_method name
> 106           define_method(name) do
  107             if instance_variable_defined?(ivar)
  108               instance_variable_get ivar
  109             else
  110               self.class.public_send name
  111             end

App backtrace

Full backtrace

  • activesupport (4.1.8) lib/active_support/core_ext/class/attribute.rb:106:in `block (2 levels) in class_attribute'
  • devise_token_auth (0.1.30) app/controllers/devise_token_auth/concerns/set_user_by_token.rb:19:in `set_user_by_token'
  • devise_token_auth (0.1.30) lib/devise_token_auth/controllers/helpers.rb:115:in `current_user'
  • devise_token_auth (0.1.30) lib/devise_token_auth/controllers/helpers.rb:103:in `authenticate_user!'
  • activesupport (4.1.8) lib/active_support/callbacks.rb:424:in `block in make_lambda'

Without omniauth

When putting this before_action :authenticate_user! on my controller

@booleanbetrayal
Copy link
Collaborator

@lynndylanhurley - also seeing the same issue. Made a quick PR ^

@Zhong-z
Copy link

Zhong-z commented Jun 5, 2015

👍
A temporary fix using monkey patch.
Added following codes in app/initializers/your_name_it.rb

DeviseTokenAuth::OmniauthCallbacksController.class_eval do
def resource_class(mapping = nil)
  if omniauth_params
    omniauth_params['resource_class'].constantize
  end              
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants