7.4 共享平台UC-mac tocken

共享平台的项目都是使用UC登录,很多接口使用的是mac tocken的验证方式,压测脚本中如果需要计算mac tocken的相关值可以导入getMacAuthorization.py模块,在接口请求之前调用相应的方法获取mac和nonce的值。

例如-预生产环境的mac tocken计算:

from getMacAuthorization import *

....

host = 'fireabc.qa.web.sdp.101.com'

uri = '/v1/users/items?user_id='+user_id

nonce_mac = getMacAuthorization('GET',uri,host,mac_key) #获取nonce和mac

Authorization = 'MAC id="'+access_token+'",'+nonce_mac

url = 'http://'+host+uri

headers = [NVPair("Content-Type","application/json"),NVPair("Authorization",Authorization)]

result = request1.GET(url,None,headers)

results matching ""

    No results matching ""