javascript code to receive Oauth token from blogger using the new api
<p>I am building a firefox extension that allows users to post to blogger.com, other blogs and social websites</p>

<p>My problem lies with receiving the Oauth token  for permission or access to be able to post on blogger.</p>

<p>I am new in javascript  and really interested in getting better, really hurts when you keep cracking at a code for days and no luck.</p>

<p>Here  are the   codes:</p>

<p>// should hold the details of the user</p>

<pre><code>var args = {};
        args.accountType = "HOSTED_OR_GOOGLE";      
        args.Email = "xyz@gmail.com";   
        args.Passwd = "xyz123";
        args.service = "blogger";       
        args.source = "xyz";    


        var argstring = "";

        for (var i in args) {
            argstring += encodeURIComponent(i) + "=" + encodeURIComponent(args[i]) + "&amp;";
        }

        argstring = argstring.substr(0, argstring.length - 1);
</code></pre>

<p>// HTTP post to google server to collect Oauth token</p>

<pre><code>        var req = new XMLHttpRequest();
        req.open("POST", "https://www.google.com/accounts/ClientLogin");
        req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        req.setRequestHeader("Content-Length", argstring.length);
        req.send(argstring);


        req.onreadystatechange = function (aEvt) {  
        if (req.readyState == 4) {  
                if(req.status == 200)  
                    alert(req.responseText);  

            else  

                    alert("Error loading page\n");  
                }  
            }
</code></pre>
