tencentyun / qcloud-cos-sts-sdk

QCloud COS STS SDK for Backend Server
MIT License
199 stars 188 forks source link

php获取临时密钥 AuthFailure.SignatureFailure #47

Closed youngda closed 3 years ago

youngda commented 3 years ago

php 7.2.13

Fatal error: Uncaught Exception: {"Error":{"Code":"AuthFailure.SignatureFailure","Message":"The provided credentials could not be validated. Please check your signature is correct."},"RequestId":"9939e6a5-cc6e-41fe-a316-3fcf64771243"}

依照例程,只改了关键信息.

`<?php

require 'vendor/autoload.php';

use QCloud\COSSTS\Sts;

$sts = new Sts(); $config = array( 'url' => 'https://sts.tencentcloudapi.com/', 'domain' => 'sts.tencentcloudapi.com', 'proxy' => '', 'secretId' => getenv('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'), // 固定密钥 'secretKey' => getenv('xxxxxxxxxxxxxxxxxxxxxxxx'), // 固定密钥 'bucket' => 'xxxxxxxxxxxxxxxxx-1252375781', // 换成你的 bucket 'region' => 'ap-nanjing', // 换成 bucket 所在园区 'durationSeconds' => 1800, // 密钥有效期 'allowPrefix' => '*', 'allowActions' => array ( // 简单上传 'name/cos:PutObject', 'name/cos:PostObject', // 分片上传 'name/cos:InitiateMultipartUpload', 'name/cos:ListMultipartUploads', 'name/cos:ListParts', 'name/cos:UploadPart', 'name/cos:CompleteMultipartUpload' ) ); // 获取临时密钥,计算签名 $tempKeys = $sts->getTempKeys($config); echo json_encode($tempKeys);`

youngda commented 3 years ago

golang 版本也试了,同样的错误{"Code: AuthFailure.SignatureFailure, Message: The provided credentials could not be validated. Please check your signature is correct., RequestId: a79217a2-af91-4ccc-ab8e-f93f459da85e"}