Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3676726
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:08:04+00:00 2026-05-19T03:08:04+00:00

So, I’m trying to use tokens with Devise (version 1.0.3 with Rails 2.3.8) to

  • 0

So, I’m trying to use tokens with Devise (version 1.0.3 with Rails 2.3.8) to let a user log in, but I’m not entirely sure where to begin.

http://zyphdesignco.com/blog/simple-auth-token-example-with-devise

The above tutorial helped me turn on the token functionality, and showed how to generate (or delete) tokens…but the whole POINT of tokens is to use them to authorize a user, correct?

When I look at a user in the console, I can say user.authentication_token, and get something back like: “Qm1ne93n_XkgmQTvxDmm”, which is all well and good…but where do I go from there?

I tried hitting the sign_in root using the following command line command:

curl -d “authentication_token=Qm1ne93n_XkgmQTvxDmm” localhost:3000/users/sign_in

And definitely didn’t get a successful log in.

In the sessions controller, I see that they call:

authenticate(resource_name)

Which I’m ASSUMING is somewhere in the module:

include Devise::Controllers::InternalHelpers

which gets included, but I don’t know where to look for that (it’s definitely not in the source’s controller folder). If I could look at how authenticate works, I could see if it even LOOKS at tokens…

DOES Devise let you actually log in with tokens, or does it just have a framework for generating them? If it does let you log in with them…HOW do you do this? Can you not use curl (i.e. does it have to be in a browser? If so, I’d hafta roll my own solution, I NEED non-browser support.). If it doesn’t, how do I roll my own?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T03:08:05+00:00Added an answer on May 19, 2026 at 3:08 am

    My understanding is that you can use the tokens to log in or to hit arbitrary pages that need authentication, even with cURL. If you look in config/initializers/devise.rb, there should be a line that says something like:

    config.token_authentication_key = :auth_token
    

    Whatever the name of the token_authentication_key is should match what you put as the query or form parameter in your request. You used authentication_token in your example, not sure if you changed devise.rb to match that or not.

    If you want to figure out how things are working internally, I would try git clone git://github.com/plataformatec/devise.git and search for the methods you need clarification of.

    Here are some sample cURL requests (I made a custom Users::SessionsController that extends Devise::SessionsController and overrides the create method to handle JSON.)

    class Users::SessionsController < Devise::SessionsController
      def create
        resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
        set_flash_message(:notice, :signed_in) if is_navigational_format?
        sign_in(resource_name, resource)
    
        respond_to do |format|
          format.html do
            respond_with resource, :location => redirect_location(resource_name, resource)
          end
          format.json do
            render :json => { :response => 'ok', :auth_token => current_user.authentication_token }.to_json, :status => :ok
          end
        end
      end
    end 
    

    And then the cURL requests I gave:

    curl -X POST 'http://localhost:3000/users/sign_in.json' -d 'user[email]=example@example.com&user[password]=password'
    -> {"response":"ok","auth_token":"ABCDE0123456789"}
    
    curl -L 'http://localhost:3000/profile?auth_token=ABCDE0123456789'
    -> got page that I wanted that needs authentication
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I need to clean up various Word 'smart' characters in user input, including but
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.