tags:

views:

34

answers:

1

Hi,

I am building a firefox extension that allows users to post to blogger.com, other blogs and social websites

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

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.

Here are the codes:

// should hold the details of the user

var args = {};
        args.accountType = "HOSTED_OR_GOOGLE";      
        args.Email = "[email protected]";   
        args.Passwd = "xyz123";
        args.service = "blogger";       
        args.source = "xyz";    


        var argstring = "";

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

        argstring = argstring.substr(0, argstring.length - 1);

// HTTP post to google server to collect Oauth token

        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");  
                }  
            }
A: 

Looking at your code you are trying to send an AJAX request to https://www.google.com. This is impossible unless you are hoisting your site on the same domain because otherwise you are violating the same origin policy.

Darin Dimitrov