我正在运行一个NodeJS演示应用程序,该应用程序建立了一个API调用并将其触发。这导致成功的响应。
我正在尝试使用CURL构建相同的API请求,但是我不知道如何以与NodeJS应用相同的方式添加Authorization标头。
当我打印发布到控制台的API请求时,它看起来像这样:
请求
Request {
_events:
[Object: null prototype] {
end:
{ [Function: bound onceWrapper] listener: [Function: bound _clearTimeout] } },
_eventsCount: 1,
_maxListeners: undefined,
_agent: false,
_formData: null,
method: 'POST',
url: 'https://myinfosgstg.api.gov.sg/test/v2/token',
_header:
{ 'user-agent': 'node-superagent/3.8.2',
'content-type': 'application/x-www-form-urlencoded',
'cache-control': 'no-cache',
authorization:
'Apex_l2_eg realm="http://localhost:3001",apex_l2_eg_timestamp="1544339067193",apex_l2_eg_nonce="154433906719300",apex_l2_eg_app_id="STG2-MYINFO-SELF-TEST",apex_l2_eg_signature_method="SHA256withRSA",apex_l2_eg_version="1.0",apex_l2_eg_signature="wEtv2BC61Y7qVoqlkMKXQEPeHI5IZnZ2LX5xShVfjCfXTbdDHYOhY+tMo0PXJO7XLM2p1dvG7f+MU0zVcpNqHW7JHSf2jdgbNLm7Zecve1V13AqLf1Q6VJzjoW4aoUOcDBIH3rR8ubCoO5hImKvJ2UNxk/KzSyhpRtOXxnqcv+aM7nwp8euWJ2N84GnW5zVkzBc2DXfw85Ctw2L/2Y9NHiLMsZ+9cf0If7Npv74ZlWFozyyMa8ho5oSBRyTkr8rkPIw262qtp8Fe+R2tsgYU3LAu2KfJpRShmhBH8/liLm6lTckUtl5ZV5uC9Y/LfOC0uh0GK1m5ojG8GtSh/LuVSA=="' },
header:
{ 'User-Agent': 'node-superagent/3.8.2',
'Content-Type': 'application/x-www-form-urlencoded',
'Cache-Control': 'no-cache',
Authorization:
'Apex_l2_eg realm="http://localhost:3001",apex_l2_eg_timestamp="1544339067193",apex_l2_eg_nonce="154433906719300",apex_l2_eg_app_id="STG2-MYINFO-SELF-TEST",apex_l2_eg_signature_method="SHA256withRSA",apex_l2_eg_version="1.0",apex_l2_eg_signature="wEtv2BC61Y7qVoqlkMKXQEPeHI5IZnZ2LX5xShVfjCfXTbdDHYOhY+tMo0PXJO7XLM2p1dvG7f+MU0zVcpNqHW7JHSf2jdgbNLm7Zecve1V13AqLf1Q6VJzjoW4aoUOcDBIH3rR8ubCoO5hImKvJ2UNxk/KzSyhpRtOXxnqcv+aM7nwp8euWJ2N84GnW5zVkzBc2DXfw85Ctw2L/2Y9NHiLMsZ+9cf0If7Npv74ZlWFozyyMa8ho5oSBRyTkr8rkPIw262qtp8Fe+R2tsgYU3LAu2KfJpRShmhBH8/liLm6lTckUtl5ZV5uC9Y/LfOC0uh0GK1m5ojG8GtSh/LuVSA=="' },
writable: true,
_redirects: 0,
_maxRedirects: 5,
cookies: '',
qs: {},
_query: [],
qsRaw: [],
_redirectList: [],
_streamRequest: false,
_data:
{ grant_type: 'authorization_code',
code: '36ece0b1-e32f-47ba-9d29-1a300c2fba2e',
redirect_uri: 'http://localhost:3001/callback',
client_id: 'STG2-MYINFO-SELF-TEST',
client_secret: '44d953c796cccebcec9bdc826852857ab412fbe2' } }
有人可以将其翻译为CURL请求吗?