开发者

How to get auth token to use contct api of google using Javascript and jQuery?

开发者 https://www.devze.com 2023-03-31 23:06 出处:网络
I want to get auth token of google using jQuery. I k开发者_运维技巧now there are many predeveloped libraries for this, but I want to this using protocol described in api documentation.try the followin

I want to get auth token of google using jQuery. I k开发者_运维技巧now there are many predeveloped libraries for this, but I want to this using protocol described in api documentation.


try the following code..

 function clientlog(Adminemail,adminpass) {  
   netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");  
   $.ajax({  
     type: 'POST',  
     url: 'https://www.google.com/accounts/ClientLogin',  
     contentType: 'application/x-www-form-urlencoded',  
     data: { accountType : "HOSTED", Email : ""+Adminemail+"", Passwd : ""+adminpass+"", service : "cp"}, // cp for contact service..
    success: function (response) {      
        var tokenArray = response.split("="); // Split to response tokenArray[3] is the auth token
        token = tokenArray[3];
        token= token.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
        alert("Done");
        $("#lable").html("you have logged in successfully..!!");
        $("#uname").val("");
        $("#pass").val("");
        $("#login").attr("disabled","disabled")
     },
     error: function(){
     $("#lable").html("Sorry Error in Login...!!");
     }
   });  
 } 
0

精彩评论

暂无评论...
验证码 换一张
取 消