I am trying to authenticate to a Google account using Google's ClientLogin method. I am tr开发者_如何学JAVAying to do this via jQuery; however, with my current code, I am getting a 405 Method Not Allowed response from Google.
Below is a sample of my code:
$(document).ready(function() {
$('#connect').click(function(){
$.ajax({
type: "POST",
contentType: "application/x-www-form-urlencoded",
url: "https://www.google.com/accounts/ClientLogin",
data: ({accountType:"HOSTED_OR_GOOGLE", Email:"user@gmail.com", Passwd:"UserPass", service:"cl", source:"User-APP-01"})
});
});
});
Thank you in advance for your assistance. Any help would be greatly appreciated.
You cant use ajax to request domain other than you running on.
U have to send data to your server, and check authorisation by ie php or something, and then return result to jquery.
You could use a php proxy or a php file dedicated to that use : https://stackoverflow.com/questions/6168509/interact-with-google-spreadsheet-from-within-javascript
精彩评论