追梦随想
追梦随想
  • 发布:2025-02-24 13:58
  • 更新:2025-02-24 13:58
  • 阅读:11

【报Bug】配置中心的app独立tokenExpiresIn不生效,仍然是全平台token过期时间

分类:uniCloud

产品分类: uniCloud/App

示例代码:
{  
    "passwordSecret": [{  
        "value": "password secret",  
        "version": 1  
    }, {  
        "type": "hmac-sha256",  
        "version": 2  
    }],  
    "tokenSecret": "token secret",  
    "tokenExpiresIn": 10800,  
    "tokenExpiresThreshold": 600,  
    "passwordErrorLimit": 6,  
    "passwordErrorRetryTime": 3600,  
    "autoSetInviteCode": true,  
    "forceInviteCode": false,  
    "app": {  
        "tokenExpiresIn": 2592000,  
        "tokenExpiresThreshold": 600,  
        "oauth": {  
            "weixin": {  
                "appid": "填写来源微信开放平台https://open.weixin.qq.com/创建的应用的appid",  
                "appsecret": "填写来源微信开放平台https://open.weixin.qq.com/创建的应用的appsecret"  
            },  
            "apple": {  
                "bundleId": "苹果开发者后台获取的bundleId"  
            }  
        }  
    },  
    "mp-weixin": {  
        "oauth": {  
            "weixin": {  
                "appid": "微信小程序登录所用的appid、appsecret需要在对应的小程序管理控制台获取",  
                "appsecret": "微信小程序后台获取的appsecret"  
            }  
        }  
    },  
    "mp-alipay": {  
        "oauth": {  
            "alipay": {  
                "appid": "支付宝小程序登录用到的appid、privateKey请参考支付宝小程序的文档进行设置或者获取,https://opendocs.alipay.com/open/291/105971#LDsXr",  
                "privateKey": "支付宝小程序登录用到的appid、privateKey请参考支付宝小程序的文档进行设置或者获取,https://opendocs.alipay.com/open/291/105971#LDsXr"  
            }  
        }  
    },  
    "service": {  
        "sms": {  
            "name": "应用名称,对应短信模版的name",  
            "codeExpiresIn": 300,  
            "smsKey": "短信密钥key,开通短信服务处可以看到",  
            "smsSecret": "短信密钥secret,开通短信服务处可以看到"  
        },  
        "univerify": {  
            "appid": "当前应用的appid,使用云函数URL化,此项必须配置",  
            "apiKey": "apiKey 和 apiSecret 在开发者中心获取,开发者中心:https://dev.dcloud.net.cn/uniLogin/index?type=0,文档:https://ask.dcloud.net.cn/article/37965",  
            "apiSecret": ""  
        }  
    }  
}

操作步骤:

不过登陆的时候我用的是uni-id-common内的API生成token

const clientInfo = this.getClientInfo();  
const {token, tokenExpired} = uniID.createInstance({clientInfo}).createToken({  
    uid: user_id  
})

预期结果:

正常返回的过期时间应该是30天(2592000秒)

实际结果:

实际返回的是两小时(7200秒)

bug描述:

/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json

该配置文件内的全平台token过期时间为

"tokenExpiresIn": 7200

app平台设置了token过期时间

"tokenExpiresIn": 2592000

经过登陆测试返回的token过期时间是两小时(7200秒),后面设置为三小时(10800秒),均能正确返回,但是app平台也单独配置了tokenExpiresIn,却完全不生效

2025-02-24 13:58 负责人:无 分享
已邀请:

要回复问题请先登录注册