百度人脸识别使用ajax获取access_token请求失败

客户要求只用前端技术完成,不能使用PHP。

$.ajax({
    url: "http://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=这是client_id&client_secret=这是client_secret&",
    type: "post",
    success: function (data) {
        alert('success')
    },
    error: function (data) {
        alert('error')
    }
});

获取Access Token请求URL数据格式
向授权服务地址https://aip.baidubce.com/oaut...(推荐使用POST),并在URL中带上以下参数:
grant_type: 必须参数,固定为client_credentials;
client_id: 必须参数,应用的API Key;
client_secret: 必须参数,应用的Secret Key;

请求结果为error(readyState0),查过资料,众说纷纭,没有找到解决方案。

求助!

阅读 1.9k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进