Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8656993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:24:49+00:00 2026-06-12T15:24:49+00:00

I am trying to use the aws sdk for php to create temporary credentials

  • 0

I am trying to use the aws sdk for php to create temporary credentials for a user. From what I can gather it should just be a case of adding the sts policy through IAM for my sdk user:

{
  "Statement": [
    {
      "Sid": "Stmt1349820612345",
      "Action": "sts:*",
      "Effect": "Allow",
      "Resource": "*"
    }
  ]
}

and then instantiating the sts class as shown in the example:

  // Instantiate the class
  $token = new AmazonSTS();

// Generate a new IAM policy
  $policy = new CFPolicy($token, array(
    'Statement' => array(
      array(
        'Sid' => 'SID' . time(),
        'Action' => array(
          's3:ListBucket'
        ),
        'Effect' => 'Allow',
        'Resource' => 'arn:aws:s3:::my-bucket'
      )
    )
  ));

// Fetch the session credentials
  $response = $token->get_federation_token('my-user', array(
    'Policy' => $policy->get_json(),
    'DurationSeconds' => 3600
  ));

  $credentials = $response->body->GetFederatedTokenResult->Credentials
    ->to_array()->getArrayCopy();
  return $credentials;

It works fine when I use the regular temporary credentials token:

$token = new AmazonSTS();
$response = $token->get_session_token();

$credentials = $response->body->GetSessionTokenResult->Credentials->to_array()->getArrayCopy();

Does anyone have a working example of this or can see where I am going wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:24:50+00:00Added an answer on June 12, 2026 at 3:24 pm

    Finally found this in the s3 docs that works

      $AccessKeyId = (string)$response->
        body->GetFederationTokenResult->Credentials->AccessKeyId;
      $SecretAccessKey = (string)$response->
        body->GetFederationTokenResult->Credentials->SecretAccessKey;
      $SessionToken = (string)$response->
        body->GetFederationTokenResult->Credentials->SessionToken;
    

    So this works

    $credentials = $response->body->GetFederationTokenResult->Credentials->to_array()->getArrayCopy();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to understand amazon php sdk for AWS but I really can't use
I am trying to use http://code.google.com/p/amazon-s3-php-class/ to force-dowload files from AWS S3. I have
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I'm trying to figure out how to create a new user with AWS APIs
I am trying to use AWS API to create a stack in AWS CloudFormation,
I am trying to use the latest SDK for PHP (v. 1.5.0). I am
I'm trying to create a signature request for amazon's AWS api using PHP. I'm
I am trying to retrieve some HTML files from Amazon s3 using AWS SDK
I am trying to implement an IAM policy where A user can only have
Im trying use count case to count records in a certain column (runs.Finish) if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.