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 6711747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:10:39+00:00 2026-05-26T08:10:39+00:00

I’m trying to build a mobile application with PhoneGap, jQuery Mobile and Backbone.js on

  • 0

I’m trying to build a mobile application with PhoneGap, jQuery Mobile and Backbone.js on the client-side – with a Rails 3 JSON API running server-side.

I know how to fetch the token from the server after being authenticated, but I don’t know how to append the “token_auth” key/value to all the AJAX-requests Backbone.js will make to my server.

Here’s my flow at the moment:

  1. User types in some form fields and hits “Log in”
  2. Backbone creates a new Player object with the email and password info.
  3. I run a Player.authenticate that sets the token to AUTHENTICATION_TOKEN
  4. All requests after this should append “auth_token=” + AUTHENTICATION_TOKEN

I’ve looked at http://documentcloud.github.com/backbone/#Sync for maybe overriding the AJAX calls – but that seems quite extreme for this simple task.

Does anyone have any experience with running Devise token_authentication and Backbone.js?

  • 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-26T08:10:40+00:00Added an answer on May 26, 2026 at 8:10 am

    Why don’t append it to all of your jquery ajax requests. It will add the auth_token to all of your ajax calls over jQuery. That might be useful when working directly with jQuery ajax (or libs that do so). But this might be a security issue as well (when you have ajax calls to other sites…).

    // this is untested
    $.ajaxSetup({ beforeSend : function(xhr, settings){ 
    
      // just because the auth_token is a private information
      if(!settings.crossDomain) {
    
        // parse data object
        var dataobj = JSON.parse(xhr.data);
    
        // add authentication token to the data object
        dataobj.auth_token = AUTHENTICATION_TOKEN;
    
        // save the dataobject into the jqXHR object
        xhr.data = JSON.stringify(dataobj); 
    
      }
    }});
    

    Another approach may be to write that token into the header and process it on the server side:

    // thats not beautiful
    $.ajaxSetup({ headers : { "auth_token" : AUTHENTICATION_TOKEN } });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I am trying to understand how to use SyndicationItem to display feed which is
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 have a jquery bug and I've been looking for hours now, I can't
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker

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.