【发布时间】:2015-05-15 22:29:59
【问题描述】:
我正在尝试使用 PHP SDK 实现开发者身份验证,但一直收到此错误:
致命错误:未捕获 Aws\CognitoIdentity\Exception\CognitoIdentityException:AWS 错误 代码:AccessDeniedException,状态代码:400,AWS 请求 ID: da162f98-fb50-11e4-937e-0bf2642a4752,AWS 错误类型:客户端,AWS 错误消息:用户:arn:aws:iam::256661818246:user/tester 不是 授权执行: 认知身份:GetOpenIdTokenForDeveloperIdentity 资源: arn:aws:cognito-identity:us-east-1:256661818246:identitypool/us-east-1:69767873-2de2-4cc7-a78f-3d18b5e9bf71, 用户代理:aws-sdk-php2/2.8.3 Guzzle/3.9.3 curl/7.20.0 PHP/5.3.6 投入 /var/www/html/aws/Aws/Common/Exception/NamespaceExceptionFactory.php 在第 91 行
这是我的示例代码:
<?php
session_start();
//Include AWS client libs
require (dirname(__DIR__).'/aws/aws-autoloader.php');
use Aws\CognitoIdentity\CognitoIdentityClient;
use Aws\Sts\StsClient;
/* Global Vars */
$aws_region = 'us-east-1';
$aws_key = '<AWS_KEY>';
$aws_secret = '<AWS_SECRET>';
$aws_account_id = '<AWS_ACCOUNT_ID>';
$identity_pool_id = 'us-east-1:xxxx-xxxx-xxxx-xxxx';
//Initialize a Cognito Identity Client using the Factory
$client = CognitoIdentityClient::factory(array('region' => $aws_region, 'key' => $aws_key, 'secret' => $aws_secret));
/* Acquire new Identity */
$identity = $client->getOpenIdTokenForDeveloperIdentity(array('IdentityPoolId' => $identity_pool_id, 'Logins' => array('login.custom.traffic' => 'jkljkasdjk')));
//Obtain Identity from response data structure
$id = $identity->get('IdentityId');
echo "IdentityId: ".$id;
?>
我怀疑在尝试获取开发者身份时发生错误。我错过了什么?
【问题讨论】: