
const tools = require('../../../tools');
const redis_help = require('../../use_redis');
const crypto = require('crypto')
const CMD = {}
CMD.get_token = async function () {
    let clinet = tools.getOneNewClinet()

    let timestamp = tools.getCurrentUnixTimestamp()
    const tmpValue = `${"eb0943539bc82bfcd2929fc35083d573"}_${timestamp}`;
    const sign = crypto.createHash('md5').update(`${"614a92b7bf79c0284b0e659faa40940b"}_${tmpValue}`).digest('hex');

    let response = await clinet.post("https://openapi-gaia.zhangyue.com/zauth/open/token/oauth",{
        access_key:"eb0943539bc82bfcd2929fc35083d573",
        signature:sign,
        timestamp:timestamp
    })

    if(response.data.code==0){
        return response.data.body.access_token
    }
    console.error("response:",response)
    return null
}

module.exports = CMD;
