Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services AWS PHP SDK-如何为联邦用户生成登录端点?_Amazon Web Services_Aws Php Sdk_Aws Sts - Fatal编程技术网

Amazon web services AWS PHP SDK-如何为联邦用户生成登录端点?

Amazon web services AWS PHP SDK-如何为联邦用户生成登录端点?,amazon-web-services,aws-php-sdk,aws-sts,Amazon Web Services,Aws Php Sdk,Aws Sts,有人能帮我使用AWS STS getFederationTokenAPI为联邦用户生成登录终点吗 以下是我的代码- <?php require 'aws-autoloader.php'; use Aws\Sts\StsClient; use Aws\Sts\Exception\StsException; $credentials = new Aws\Credentials\Credentials('MYKEY', 'MYSECRET'); $client = new StsClien

有人能帮我使用AWS STS getFederationTokenAPI为联邦用户生成登录终点吗

以下是我的代码-

<?php
require 'aws-autoloader.php';
use Aws\Sts\StsClient; 
use Aws\Sts\Exception\StsException;

$credentials = new Aws\Credentials\Credentials('MYKEY', 'MYSECRET');

$client = new StsClient([
    'region' => 'ap-south-1',
    'version' => '2011-06-15',
    'credentials' => $credentials
]);


try {
    
    $result = $client->getFederationToken(array(
    // Name is required
    'Name' => 'sv',
    'Policy' => '{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": [
    "sns:*"
      ],
      "Effect": "Allow",
      "Resource": "*"
    }
  ]
}',
    'DurationSeconds' => 28000,
));

    //echo '<pre>'; print_r($result);die;
   

$json_data = json_encode(['sessionId' => '$result["Credentials"]["AccessKeyId"]',
                        'sessionKey' => '$result["Credentials"]["SecretAccessKey"]',
                        'sessionToken' => '$result["Credentials"]["SessionToken"]'
]);

$issuer = urlencode("https://signin.aws.amazon.com/");

$destination = urlencode("https://console.aws.amazon.com/sns");

$sign_in_url = "https://signin.aws.amazon.com/federation?Action=getSigninToken&SessionType=json&Session=".urlencode($json_data);

$ch = curl_init();

// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$sign_in_url);
// Execute
$result=curl_exec($ch);

// Closing
curl_close($ch);

// Print the return data
$res = json_decode($result, true);

$sign_in_token = $res['SigninToken'];

$login_url = "https://signin.aws.amazon.com/federation?Action=login&Issuer=".$issuer."&Destination=".$destination."&SigninToken=".$sign_in_token;

echo $login_url;

} catch (StsException $e) {
    // output error message if fails
    print_r($e->getMessage());
}