I am using the following example code to fetch details. And it's giving error:
amazonproduct.errors.InvalidClientTokenId: InvalidClientTokenId: The
AWS Access Key Id you provided does not exist in our records.
The same is working while I used in PHP. I generated the key going to IAM Console.
access_key = '***'
secret_key = '***'
associate_tag = 'ptab-20'
api = API(locale='us')
result = api.item_lookup('B006H3MIV8')
for item in result.Items.Item:
print '%s (%s)' % (item.ItemAttributes.Title, item.ASIN)
Somehow python-amazon-product-api is not considering the config file i.e. ~/.amazon-product-api. Alternatively you can specify your credentials directly when instantiating API object by
api = API(AWS_KEY, SECRET_KEY, "us")
Related
I'm trying to set up Dialogflow on a php backend. According to the documentation: https://googleapis.dev/nodejs/dialogflow/latest/v2beta1.SessionsClient.html
I should be able to pass as a parameter the path of the json key file I previously generated with the Google Cloud Console to access DialogFlow's API.
$path = dirname(__DIR__, 2) . '\_________-_______-____________.json';
$config = [
'keyFilename' => $path,
];
$sessionsClient = new SessionsClient($config);
I keep getting this error: Could not construct ApplicationDefaultCredentials
I double checked the path using the file_get_contents method, it's valid.
Any idea ?
Something is wrong with the doc.
Using the key credentials instead of keyFilename did the work.
I am working on new Alexa.com Api and testing it out and I having a problem setting credentials in it. I have an access key and secret key but not Session Token and Expiration.Idk where to get them.
Also see this
$awsCredentials = $result->get('Credentials');
and I could not find its root to set credentials.
I have an access key and secret key for my Alexa API calls. And I have setup up AWS SDK for PHP 3
protected function SetCredentials($awsCredentials) {
$this->accessKeyId = $awsCredentials["AccessKeyId"];
$this->secretAccessKey = $awsCredentials["SecretKey"];
$this->sessionToken = $awsCredentials["SessionToken"];
$this->expiration = $awsCredentials["Expiration"];
}
How do I set credentials?
Here is the urlinfo.php code:
https://github.com/aws-samples/alexa-web-information-service-api-samples/blob/master/php/urlinfo.php
You have a problem in your php version or your account is not verified.
I am using the Twilio PHP helper library.
I have several subaccount credentials stored in the database. Each subaccount usually has several outgoing caller ids associated with it.
I use the credentials for each subaccount to get the outgoingCallerIds.
From the data returned, I take the subaccount SID (AC) and the number SID (PN).
I follow the documentation and am receiving errors on each attempt to update master with the numbers from the subaccounts.
Caught exception: [HTTP 404] Unable to update record: The requested
resource
/2010-04-01/Accounts/ACxxxxxxxxxxxxxx/IncomingPhoneNumbers/PNxxxxxxxx.json
was not found
I have checked the account sids and number sids and they are correct.
Any idea where I'm going wrong here?
Here is my Try that happens in a foreach which credentials for every subaccount.
try
{
$client = new Client($sid, $token); //subaccount sid and token from not shown foreach
$caller_ids = $client->outgoingCallerIds->read();
foreach ($caller_ids as $caller_id)
{
$phone_number = $caller_id->phoneNumber;
$friendly_name = $caller_id->friendlyName;
$number_sid = $caller_id->sid;
$account_sid = $caller_id->accountSid;
$incoming_phone_number = $master_account->incomingPhoneNumbers("$number_sid")
->update(
array("accountSid" => "$account_sid")
);
}
}
Twilio developer evangelist here.
I believe the issue here is that you are using the master account sid to refer to the number that sits within the subaccount thus getting a 404. Instead you should select the subaccount from within the master account's list of accounts, and use that subaccount object to refer to the number as you transfer it.
For example:
$subaccount = $master_account->accounts($subaccount_sid);
$incoming_phone_number = $subaccount->incomingPhoneNumbers($number_sid)
->update(
array("accountSid" => $master_account->sid)
);
Let me know if this helps at all.
Am having some issues getting AWS SES working per below; I want to send an email to users from my website. Looks like the credentials are not being validated, however I have used the correct credentials generated from an IAM (I also tried the server root keys and it gave me the same error). I have run out of ideas of how to resolved/ debug any further so any steer would be greatly appreciated.
Error Received on Execution:
Error retrieving credentials from the instance profile metadata server. (Client error: 404)
Steps Taken
I have setup SES and validated the email addresses etc
I have created a IAM profile with 'Full access to SES'
I have installed the AWS SDK for php using the phar file
I have written the php code below providing the correct security access code directly of the SES
require 'aws/aws.phar';
use Aws\Ses\SesClient;
//More code here
$client = SesClient::factory(array(
'key' => 'xxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxx',
'region' => 'us-west-2',
'version' => '2010-12-01'
));
//code to build the $msg here as array
try{
$result = $client->sendEmail($msg);
//save the MessageId which can be used to track the request
$msg_id = $result->get('MessageId');
echo("MessageId: $msg_id");
//view sample output
print_r($result);
} catch (Exception $e) {
echo($e->getMessage());
}
//view the original message passed to the SDK
print_r($msg);
Thank you for your help in advance - this is always a great community!! Please let me know if i can provide anything else
John
You can provide credentials to your SDK using multiple methods. See the documentation: Providing Credentials to SDK
1) Set the environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION with the values from the IAM profile you created.
2) Instead of 1), you can also create ~/.aws/credentials file. Here you can add the lines: [default]
aws_access_key_id = YOUR_AWS_ACCESS_KEY_ID
aws_secret_access_key = YOUR_AWS_SECRET_ACCESS_KEY
aws_default_region = the region
1) or 2) will definitely work and it is straight forward.
3) You can also create instance profile. You need to create IAM role and instance profile. Your instance needs to have instance profile assigned when it is being created. See page 183 (as indicated on bottom of page. The topic name is "Using an IAM Role to Grant Permissions to Applications
Running on Amazon EC2 Instances") of this guide: AWS IAM User Guide to understand the steps and procedure. Here, the secret key and access key are automatically picked up and you don't have to do anything. You just need to set default region using step 1) (i.e, export AWS_DEFAULT_REGION=someregion).
4) You have already tried the 4th method and may be there is some issue in your settings which I am not aware of.
I am new to both PHP and Amazon SimpleDB. I am trying to figure out how to update values in SimpleDB. I created a signature which returns a value so I believe that is working. When I try to follow Amazon's PutAttribute example, my application breaks. Any hints or ideas of what I could be doing wrong would be greatly appreciated.
$item_name = htmlspecialchars($_POST["item_name"]);
$timestamp = gmdate('c');
$secretkey = 'mysecretkey';
$accesskey = 'myaccesskey';
$message = "
https://sdb.amazonaws.com/
?Action=PutAttributes
&Attribute.1.Name=body_type
&Attribute.1.Value=02
&Attribute.1.Replace=true
&AWSAccessKeyId=[my access key]
&DomainName=FILE_LOG_DEV
&ItemName={$item_name}
&SignatureVersion=2
&SignatureMethod=HmacSHA256
&Timestamp={$timestamp}
&Version=2009-04-15
";
$signature = base64_encode(hash_hmac('sha1', $message, $secretkey, true));
https://sdb.amazonaws.com/
?Action=PutAttributes
&Attribute.1.Name=body_type
&Attribute.1.Value=02
&Attribute.1.Replace=true
&AWSAccessKeyId=[my access key]
&DomainName=FILE_LOG_DEV
&ItemName=$item_name
&SignatureVersion=2
&SignatureMethod=HmacSHA1
&Timestamp=$timestamp
&Version=2009-04-15
&Signature=$signature
You can use AWS PHP SDK (link) that will help you to interact with Amazon SimpleDB Database Service in easy and friendly manner. AWS PHP SDK will internally manage your creating signature and time stamp. So you need to only focus on parameters pass to your method and result what you get from that method. Have a look on example. Here it will take an array as argument and returns a response Model object.