Closed garspace closed 5 years ago
请检查自己的密钥是否有空格,少复制或者多了字符
用url可以,base64有问题
如果是python3,注意base64出来的是字节而不是字符串,转换下应该就可以了。
@liny23 你的密钥已经泄漏了。请到官网控制台-访问管理-密钥管理禁用此密钥。你是python3的环境吗?base64.b64encode在python2下是字符串,在python3下是字节。SDK要求此字段是字符串,在python3下你得把base64.b64encode得到的返回转为字符串。
关注,同一个问题,url可以,BASE64不行,麻烦看下
@liny23 你的密钥已经泄漏了。请到官网控制台-访问管理-密钥管理禁用此密钥。你是python3的环境吗?base64.b64encode在python2下是字符串,在python3下是字节。SDK要求此字段是字符串,在python3下你得把base64.b64encode得到的返回转为字符串。
关注,和楼主同一个问题,url可以,BASE64不行,麻烦看下
我已经将secret id和key换成我自己的了,但是不明白为什么还报签名的错误, cred = credential.Credential( "xxx", "xxx") httpProfile = HttpProfile() httpProfile.endpoint = "ocr.tencentcloudapi.com"
clientProfile = ClientProfile() clientProfile.httpProfile = httpProfile client = ocr_client.OcrClient(cred, "ap-guangzhou", clientProfile)
req = models.GeneralBasicOCRRequest() with open('E:\dj\pixel_link-master\img\415.jpg','rb') as f: img = f.read() img_base64 = base64.b64encode(img) req.ImageBase64 = img_base64 resp = client.GeneralBasicOCR(req) print(resp.to_json_string())
错误信息如下: raise TencentCloudSDKException(code, message, reqid) tencentcloud.common.exception.tencent_cloud_sdk_exception.TencentCloudSDKException: [TencentCloudSDKException] code:AuthFailure.SignatureFailure message:The provided credentials could not be validated. Please check your signature is correct. requestId:f5284213-7aa3-4e14-aff5-41866aab0ca1