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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:48:58+00:00 2026-05-14T04:48:58+00:00

EDIT: This question is now redundant since Twitter no longer supports basic auth. I’ve

  • 0

EDIT: This question is now redundant since Twitter no longer supports basic auth. I’ve left it up since it’s relevant to anyone doing basic auth via AJAX on other services.


I’m developing a javascript App that needs, as part of its functionality, for users to be able to update their Twitter status. The App is designed to work on mobiles, and as such I don’t really want to be sending users all the way over to the Twitter site to sign in; they should just be able to pass their credentials to the app, and I’ll handle all the signin.

So I’m trying to use the Basic Auth with the restful API. My code looks like:

function postTweet(input){
            $.ajax( {
                type: "POST",
                url: "http://twitter.com/statuses/update.json",
                data: {status: input},
                dataType: "json",
                error: function() { alert("Some error occured"); },
                success: function() { alert("Success!"); },
                beforeSend: function(request) { request.setRequestHeader("Authorization", "Basic BASE64OFMYCREDENTIALS");}
                } ) ;
        }

So, as far as I’m aware, this should perform the authentication from the XMLHttpRequest header, and then post the status.

However, whenever I call this code, I get a “401 Unauthorized” error from Twitter.

Below are the request & response headers from firebug:

Request:

OPTIONS /statuses/update.json HTTP/1.1
Host: twitter.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Origin: null
Access-Control-Request-Method: POST
Access-Control-Request-Headers: authorization

Response:

HTTP/1.1 401 Unauthorized
Date: Sat, 13 Mar 2010 11:08:58 GMT
Server: hi
Status: 401 Unauthorized
WWW-Authenticate: Basic realm="Twitter API"
X-Runtime: 0.00204
Content-Type: application/json; charset=utf-8
Cache-Control: no-cache, max-age=300
Set-Cookie: guest_id=1268478538488; path=/
_twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCPlyNlcnAToHaWQiJWUyN2YzYjc3OTk2NGQ3%250ANzJkYTA4MjYzOWJmYTQyYmUyIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--d687808459872da0aa6a89cab35fd347300b4d07; domain=.twitter.com; path=/
Expires: Sat, 13 Mar 2010 11:13:58 GMT
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 88
Connection: close

Any help with this would be much appreciated,

Thanks,

jelford

ps. I should mention I’m using JQuery, incase it’s not clear.

  • 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-14T04:48:58+00:00Added an answer on May 14, 2026 at 4:48 am

    Since the App was eventually going to be Client-Side only (It was designed for the JIL Mobile Platform), I decided to bite the bullet and do full OAuth, and just accept that it wasn’t going to work if you opened it as a web page in Firefox.

    What’s puzzling to me is that – whilst I know POSTs will never work in the browser – I thought by setting the Auth headers in the HTTPRequest object and still making a GET request that would all go fine. Apparently not.

    The point’s mute now, since the App passed its deadline (got it finished 🙂 ), but I thought someone might like to know that I didn’t get it working through the basic auth route.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 376k
  • Answers 376k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Resolved. I inserted a query_results->next() before retrieving the data and… May 14, 2026 at 8:36 pm
  • Editorial Team
    Editorial Team added an answer What you can do is have a single main dialog… May 14, 2026 at 8:36 pm
  • Editorial Team
    Editorial Team added an answer Okay, I got the files by downloading the Firefox source.… May 14, 2026 at 8:36 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.