阿里云STS报错 UnknownServerError The server returned an error without a detailed message:
Error: UnknownServerError Message: UnknownServerError The server returned an error without a detailed message. HTTP Status: 404 RequestID: None
\DefaultProfile::addEndpoint(REGION_ID, REGION_ID, 'Sts', ENDPOINT);
第三个参数products 不要用示例给出的'Sts',随便什么都行。
若policy为空,则用户将获得该角色下所有权限,参见java示例
完整代码如下:
define("REGION_ID", "cn-beijing");
define("ENDPOINT", "oss-cn-beijing.aliyuncs.com");
define("PRODUCTS", "Sts_test");
$acccess_key_id = '';
$access_key_secret = '';
\DefaultProfile::addEndpoint(REGION_ID, REGION_ID, PRODUCTS, ENDPOINT);
$iClientProfile = \DefaultProfile::getProfile(REGION_ID, $acccess_key_id, $access_key_secret);
$client = new \DefaultAcsClient($iClientProfile);
//sts控制台配置
$roleArn = "";
$request = new Sts\AssumeRoleRequest();
$request->setRoleSessionName("session-name");
$request->setRoleArn($roleArn);
$request->setDurationSeconds(3600);
try {
$response = $client->getAcsResponse($request);
print_r($response);
} catch(\ServerException $e) {
print "Error: " . $e->getErrorCode() . " Message1: " . $e->getMessage() . "\n";
} catch(\ClientException $e) {
print "Error: " . $e->getErrorCode() . " Message2: " . $e->getMessage() . "\n";
}
网友评论