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

Help: Unable to authenticate with HTTP Get query for multiple models added to Devise #327

Open
Guillaumejfrt opened this issue Feb 2, 2018 · 0 comments
Labels
support request This issue is a request for support using Simple Token Authentication.

Comments

@Guillaumejfrt
Copy link

Guillaumejfrt commented Feb 2, 2018

Hi @gonzalo-bulnes,

I was used to use simple_token_authentication with one User model. It worked perfectly. I could authenticate the user through HTTP get query with:

localhost:3000/fb_users/**?user_email=***********&user_token=*****************

Then, I added Devise to my FbUser model that I also want to authenticate through HTTP Get query.
Thus, I run the migration:

class AddAuthenticationTokenToFbUsers < ActiveRecord::Migration[5.1]
  def change
    add_column :fb_users, :authentication_token, :string, limit: 30
    add_index :fb_users, :authentication_token, unique: true
  end
end

added the helpers in the model and in the controller:

class FbUser < ApplicationRecord
  # Authenticate fb_user to display on boarding questionnaire in Messenger webview
  acts_as_token_authenticatable
class FbUsersController < ApplicationController

  acts_as_token_authentication_handler_for User
  acts_as_token_authentication_handler_for FbUser

So, I have those two queries:

localhost:3000/fb_users/**?user_email=***********&user_token=*****************

and

localhost:3000/fb_users/**?fb_user_email=***********&fb_user_token=*****************

Despite that, I always get a 401 error when I launch the query. Here are my logs:

Started GET "/fb_users/**?user_email=***********&user_token=***********" for 127.0.0.1 at 2018-02-02 17:29:38 +0100
Processing by FbUsersController#show as HTML
  Parameters: {"user_email"=>"***********", "user_token"=>"***********", "id"=>"29"}
Completed 401 Unauthorized in 17ms (ActiveRecord: 0.0ms)

and

Started GET "/fb_users/29?fb_user_email=***********&fb_user_token=***********" for 127.0.0.1 at 2018-02-02 17:13:49 +0100
Processing by FbUsersController#show as HTML
  Parameters: {"fb_user_email"=>"***********", "fb_user_token"=>"***********", "id"=>"29"}
Completed 401 Unauthorized in 1ms (ActiveRecord: 0.0ms)

Would know how to help me?

Thanks a lot
Guillaume

@Guillaumejfrt Guillaumejfrt changed the title Unable to authenticate with HTTP Get query for multiple models added to Devise Help: Unable to authenticate with HTTP Get query for multiple models added to Devise Feb 2, 2018
@gonzalo-bulnes gonzalo-bulnes added the support request This issue is a request for support using Simple Token Authentication. label Jan 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support request This issue is a request for support using Simple Token Authentication.
Projects
None yet
Development

No branches or pull requests

2 participants