近期项目需要对接阿里云的api,用接口调用时需要使用签名机制。
文档是明明白白的,自己接入时遇到些小插曲。
1、时间问题,使用了几种方法转换都没成功
Message: 'The input parameter "Timestamp" that is mandatory for processing this request is not supplied.'
最后发现下面这个转换才是正确
moment(new Date()).utcOffset(0).format()
2、percentEncode时漏了一个地方,报错如下:
Message: 'The request signature does not conform to Aliyun standards. server string to sign is:***
务必按照红框规定来转换。
3、待签名的字符串,务必要与官方基本相同,除了变量的字段外,我不小心将其他字段加进去了,就一直报错
Message: 'The request signature does not conform to Aliyun standards. server string to sign is:***