【发布时间】:2019-07-23 22:17:27
【问题描述】:
如何将以下 curl 请求转换为 Angular 7 中的 HTTP post 请求?
curl --request POST \
--url https://api.typeform.com/oauth/token \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'code={temporary_authorization_code}' \
--data-urlencode 'client_id={your_client_id}' \
--data-urlencode 'client_secret={your_client_secret}' \
--data-urlencode 'redirect_uri=https://results-example.herokuapp.com/callback'
我尝试了下面的方法,但它不起作用
this.httpClient.post(environment.typeForm.base_url + 'token', JSON.stringify({
'grant_type' : 'authorization_code',
'code': `${authCode}`,
'client_id':`${*******}`,
'client_secret':`${*******}` ,
'redirect_uri':`${*******}`,
}));
grant_type 应该是 typeform 文档中指定的“authroization_code”。
这是我得到的错误
{"headers":{"normalizedNames":{},"lazyUpdate":null},"status":500,"statusText":"Internal Server Error","url":"https://api.typeform.com/oauth/token","ok":false,"name":"HttpErrorResponse","message":"Http failure response for https://api.typeform.com/oauth/token: 500 Internal Server Error","error":{"code":"internal_server_error","description":"Internal server error"}}
您可以找到我正在尝试使用的 API 的文档here
【问题讨论】:
-
您好,您能告诉我们您目前的尝试吗?
-
@sedders123 我已经用我迄今为止尝试过的内容和我得到的错误更新了这个问题