请问解决了吗
小程序上传图片到阿里oss之后报403?[图片] OSSAccessKeyId和accessKeySecret从服务器获取。 signature和policy是前端生成的, 这是请求参数 [图片] 这是代码 handleUpload = async (files:any) => { Taro.showToast({title: '上传中'}) let { dir, ossToken } = this.state const policyBase64 = this.getPolicyBase64() const signature = this.getSignature(policyBase64) console.log('ossToken', ossToken) let newArr = files.map((item:any) => { let formData = { key: dir + item.substring(item.lastIndexOf('/')+1), policy: policyBase64, OSSAccessKeyId: (ossToken as any).accessKeyId, signature, success_action_status: '200' } console.log('formData', formData) return Taro.uploadFile({ url: (ossToken as any).filePath, filePath: item, header: { "Content-Type": "multipart/form-data" }, name: 'file', formData }) }) let resArr = await Promise.all(newArr) Taro.hideLoading() console.log(resArr) } getPolicyBase64 = ():string => { let date = new Date(); date.setHours(date.getHours() + 700 * 1000); let srcT = date.toISOString(); const policyText = { "expiration": srcT, //设置该Policy的失效时间,超过这个失效时间之后,就没有办法通过这个policy上传文件了 "conditions": [ ["content-length-range", 0, 5*1024 * 1024] // 设置上传文件的大小限制,5mb ] }; const policyBase64 = Base64.encode(JSON.stringify(policyText)); return policyBase64 } getSignature = (policyBase64:string) => { let { ossToken } = this.state const accesskey = (ossToken as any).accessKeySecret const signature = Crypto.enc.Base64.stringify(Crypto.HmacSHA1(accesskey, policyBase64)) console.log(signature) return signature }
2022-06-06我也遇到了这个问题,确认平台已经获取了登录接口权限,回调域名也设置了,还是这样,请问楼主问题解决了吗
Scope 参数错误或没有 Scope 权限https://open.weixin.qq.com/connect/qrconnect?appid=我的appid&redirect_uri=http%3A%2F%2Fwww.21sjwl.com%2FUsers%2FweChatLogin&response_type=code&scope=snsapi_login&state=3d6be0a4035d839573b04816624a415e#wechat_redirect
2020-10-05