Tag: lyft api

使用axios获取访问令牌

我正在使用Lyft API ,并试图找出如何使用axios和节点脚本获取访问令牌。 我可以通过使用Postman手动获取访问令牌,填写如下所示的表单: 当我填写表格时,我可以成功地从Lyft获得一个新的令牌。 我试图把这个转换成使用axios POST请求通过这样做: var axios = require('axios'); var data = { "grant_type": "client_credentials", "scope": "public", "client_id": "vaf7vX0LpsL5", "client_secret": "pVEosNa5TuK2x7UBG_ZlONonDsgJc3L1" }; var url = "https://api.lyft.com/oauth/token"; return axios.post(url, data) .then(function(response){ console.log(response.data) }) .catch(function (error) { console.log(error); }); 当我运行脚本时,我得到这个错误: { error_description: 'Unauthorized', error: 'invalid_client' } 我从axios请求中遗漏了什么? 任何帮助,将不胜感激!