【发布时间】:2022-01-21 06:47:36
【问题描述】:
我正在尝试使用 axios 发送一个帖子请求,我想知道是否有人有一些意见。
let grant_type: string = 'authorization_code'
await axios
.post(
url,
{
client_id: client_id,
client_secret: client_secret,
grant_type: grant_type,
redirect_uri: redirect_uri,
code: code,
},
{
headers: { 'Content-Type': 'application/x-www.form-urlencoded' },
},
)
.then((response) => {
functions.logger.log('---Response---')
functions.logger.log(response)
return response
})
.catch((error) => {
functions.logger.log(error)
return error
})
我得到的错误是
error_description: 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "grant_type" parameter.'
如果有人可以提供帮助,那就太好了,我很茫然,我已经尝试使用邮递员进行 api 调用,一切正常,但是当我尝试使用 firebase 函数时,它不起作用。
谢谢!
【问题讨论】:
-
请显示每个变量的确切值,或至少显示
grant_type的值(因为这是错误消息所说的错误)。 -
让 grant_type: string = 'authorization_code'
标签: firebase axios google-cloud-functions