美文网首页
阿里云STS报错

阿里云STS报错

作者: 良先生爱生活 | 来源:发表于2019-12-09 17:45 被阅读0次

    阿里云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示例

    1.png

    完整代码如下:

           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";
           }
    

    相关文章

      网友评论

          本文标题:阿里云STS报错

          本文链接:https://www.haomeiwen.com/subject/jzkigctx.html