通过 jQuery 实现 Google ClientLogin
我正在尝试使用 Google 的 ClientLogin 方法对 Google 帐户进行身份验证。我正在尝试通过 jQuery 来做到这一点;但是,使用我当前的代码,我收到来自 Google 的 405 Method Not allowed 响应。
以下是我的代码示例:
$(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:"[email protected]", Passwd:"UserPass", service:"cl", source:"User-APP-01"})
});
});
});
提前感谢您的帮助。任何帮助将不胜感激。
I am trying to authenticate to a Google account using Google's ClientLogin method. I am trying 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:"[email protected]", Passwd:"UserPass", service:"cl", source:"User-APP-01"})
});
});
});
Thank you in advance for your assistance. Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不能使用 ajax 来请求您运行的域以外的域。
你必须将数据发送到你的服务器,并通过ie php或其他东西检查授权,然后将结果返回给jquery。
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.
您可以使用 php 代理或专用于该用途的 php 文件: https:/ /stackoverflow.com/questions/6168509/interact-with-google-spreadsheet-from-within-javascript
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