Skip to content

RESTFUL接口调用身份验证

前言

该身份验证仅适用文档中的RESTFUL接口

接口验证的主要流程是使用appid、secret将接口所有参数进行加密,生成签名,将签名作为请求参数sign的值

GET请求

演示接口 https://glm.glodon.com/glm/api/open/testGET?
appid=XXX&sign=XXX&a_param1=XXX&b_param2=XXX
演示appid test_appid
演示secret test_secret

1.生成加密前字符串

将请求参数中除sign外的所有参数拼接到此字符串中,前后拼接上secret
参数拼接的顺序按字母顺序排列

test_secret appidtest_appid a_param1XXX b_param2XXX test_secret

2.加密字符串生成签名

将1中生成的字符串使用MD5加密,生成32位大写字符串

TESTTESTTESTTESTTESTTESTTESTTEST

3.拼接成完整url

https://glm.glodon.com/glm/api/open/testGET?appid=test_appid&sign=TESTTESTTESTTESTTESTTESTTESTTEST&a_param1=XXX&b_param2=XXX

POST请求

POST接口验证sign在请求的header中传递,需要拼接appid及系统当前毫秒时间戳

演示接口 https://glm.glodon.com/glm/api/open/testPOST
演示appid test_appid
演示secret test_secret

1.生成加密前字符串

拼接appid及系统当前毫秒时间戳,时间戳参数名为ts,前后拼接上secret

test_secret appidtest_appid ts1557816297000 test_secret

2.加密字符串生成签名

将1中生成的字符串使用MD5加密,生成32位大写字符串

TESTTESTTESTTESTTESTTESTTESTTEST

3.在请求header加入

请求header:
appid:test_appid
ts: 1557816297000
sign: TESTTESTTESTTESTTESTTESTTESTTEST