How to call Amazon API using zend framework? 403 error return - zend-framework

I am trying to fetch data from Amazon API through zend framework. I registered an aws account, and put the access id, secret key in according to zend's official tutorial.
here is the code:
$amazon = new Zend_Service_Amazon('my access ID','US','my secret key');
$results = $amazon->itemSearch(array('SearchIndex' => 'Music', 'Keywords' => 'music'));
I got the error message:
Message: An error occurred sending request. Status code: 403
anybody help?

This happens when your server does not have route.

Related

Google API Client Error: the caller does not have permission

I'm trying to use the Google API Client to gain access to a Google Doc. I get the following error:
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://docs.googleapis.com/v1/documents/1Dc82X_w8UsyZnJe5JEh4E0wNdfbw-_nhVWXwgEJ4HVg?alt=json returned "The caller does not have permission". Details: "The caller does not have permission">
The error comes up in the file extract_text.py, which I got from here: https://developers.google.com/docs/api/samples/extract-text
Specifically, the error shows up at this line when it's obtaining the document's ID:
doc = docs_service.documents().get(documentId=documentID).execute()
The error states that my request has invalid authentication credentials (https://cloud.google.com/asset-inventory/docs/faq). I have made sure that I setup the OAuth correctly.

EPROTO error on google action verification

I am working on an action on google using Actions SDK, however when i enabled the Actions; verification as described at:
https://developers.google.com/actions/reference/rest/verify-requests
I am getting the below error, this only comes when i am behind corporate proxy, can anyone suggest a solution for this?
{
"error": "ID token verification failed: Error: Failed to retrieve verification certificates: Error: write EPROTO 139904972138304:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:825:\n\n at OAuth2Client. (/opt/app/node_modules/actions-on-google/node_modules/google-auth-library/build/src/auth/oauth2client.js:580:31)\n at step (/opt/app/node_modules/actions-on-google/node_modules/google-auth-library/build/src/auth/oauth2client.js:57:23)\n at Object.throw (/opt/app/node_modules/actions-on-google/node_modules/google-auth-library/build/src/auth/oauth2client.js:38:53)\n at rejected (/opt/app/node_modules/actions-on-google/node_modules/google-auth-library/build/src/auth/oauth2client.js:30:65)\n at propagateAslWrapper (/opt/.npm-global/lib/node_modules/ca-apm-probe/node_modules/async-listener/index.js:502:23)\n at /opt/.npm-global/lib/node_modules/ca-apm-probe/node_modules/async-listener/glue.js:188:31\n at /opt/.npm-global/lib/node_modules/ca-apm-probe/node_modules/async-listener/index.js:539:70\n at /opt/.npm-global/lib/node_modules/ca-apm-probe/node_modules/async-listener/glue.js:188:31\n at :null:null\n"
}
I am using v2.5.0 of actions-on-google
So i was able to sort this issue, the underlying issue is with axios library being used by google auth library (v1.3.2)
here is the issue : https://github.com/axios/axios/issues/662
The workaround for me was to replace axios with request promise in google auth library and then publish it in our private npm registry, this solved the issue for now.

Ruby gem facebook_ads exception_with_response: 400 Bad Request

I'm trying to query the Facebook Marketing API Insights using the facebook_ads Ruby gem. https://github.com/tophatter/facebook-ruby-ads-sdk
I created an app and have Editor permissions on the relevant pages for my company.
Next, I generated a user access token from this page after selecting ads_management permissions.
Next, I followed the instructions on this page to get a permanent page access token.
With the code below I get this error:
/var/lib/gems/2.3.0/gems/rest-client-/var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/abstract_response.rb:223:in exception_with_response': 400 Bad Request (RestClient::BadRequest)
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/abstract_response.rb:103:inreturn!'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:809:in process_result'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:725:inblock in transmit'
from /usr/lib/ruby/2.3.0/net/http.rb:853:in start'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:715:intransmit'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:145:in execute'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:52:inexecute'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient.rb:67:in get'
from /var/lib/gems/2.3.0/gems/facebook_ads-0.6.6/lib/facebook_ads/base.rb:15:inget'
from /var/lib/gems/2.3.0/gems/facebook_ads-0.6.6/lib/facebook_ads/ad_account.rb:10:in `all'
I have also tried this code with my temporary user access code but get the same result.
Here is my code
#!/usr/bin/ruby
require 'facebook_ads'
MY_PAGE_PERMANENT_ACCESS_CODE = 'my access code'
APP_SECRET = 'my app secret'
FacebookAds.access_token = MY_PAGE_PERMANENT_ACCESS_CODE
FacebookAds.app_secret = APP_SECRET
accounts = FacebookAds::AdAccount.all
It turns out that I was using the page permanent access token which was out of scope for the API call. I needed to use my temporary user access code.
E, [2019-01-19T00:08:49.366067 #19868] ERROR -- : GET /me/adaccounts
OAuthException / 100: (#100) Tried accessing nonexisting field
(adaccounts) on node type (Page) RestClient::BadRequest: 400 Bad
Request
In the pry console for the gem I ran this command to set the account variable:
pry(main)> account = FacebookAds::AdAccount.find('act_MY_ACCOUNT_ID')
and I get this error:
E, [2019-01-19T00:12:24.760545 #20188] ERROR -- : GET /me/adaccounts
OAuthException / 2635: (#2635) You are calling a deprecated version of
the Ads API. Please update to the latest version: v3.2.
RestClient::BadRequest: 400 Bad Request
So, I ran this command:
pry(main)> FacebookAds.base_uri = 'https://graph.facebook.com/v3.2'
"https://graph.facebook.com/v3.2"
Then pry(main)> account = FacebookAds::AdAccount.find('act_MY_ACCOUNT_ID') again.
Finally, I ran:
pry(main)> account.ad_insights
but the result is an empty array when I know this should not be blank. I'm going to skip the gem and use Ruby net/http to query the API directly.

How to solve Android GCM 401 Error?

Have setup a project at Google Code APis console and have a server key at "Key for server apps (with IP locking)". I'am trying to send a push notification to GCM device using "API key" and one registration ID that I have stored at database.
For server side I'am using Zend_Mobile_Push_Gcm and have something like this:
$token = 'REGISTRATION ID';
$apiKey = 'API KEY';
//Send test push
$message = new Zend_Mobile_Push_Message_Gcm();
$message->setId(time());
$message->addToken($token);
$message->setData(array('foo' => 'bar', 'bar'=>'foo'));
$gcm = new Zend_Mobile_Push_Gcm();
$gcm->setApiKey($apiKey);
try {
$response = $gcm->send($message);
} catch (Zend_Mobile_Push_Exception $e) {
die($e->getMessage());
}
On the app side, I have used the GCM demo, that is currently registering it's registration ID on a server service.
I'am not able to send the push, always get a 401 error. Have gone through troubleshooting and tried my API KEY and Registration ID with the CLI test line at http://developer.android.com/guide/google/gcm/gcm.html#auth_error but with no success.
Any help would be appreciated.
I realise this was posted a while ago but be sure to use your server API key and not your android API key.
I had the same issue when trying to use my Android API key from PHP with Zend.

ACS/Facebook Integration - ACS40001: An error occurred while attempting to get an access token from Facebook

Getting the following error setting up ACS/Facebook integration:
HTTP Error Code: 502 Message: ACS40000: An error occurred while
processing a Facebook sign-in response. This may be caused by invalid
configuration of the Facebook application. Inner Message: ACS40001:
An error occurred while attempting to get an access token from
Facebook. Inner Message: ACS90005: Web exception Trace ID:
988ec1a7-e02b-4dcf-abab-51812745a121 Timestamp: 2011-07-12 19:59:51Z
I've verified that App ID, App Secret, Site URL and Site Domain have all been set.
For Site Url, we're using https://project.accesscontrol.windows.net
For Site Domain, we're using project.accesscontrol.windows.net
I'm using the following as a guideline:
http://blogs.objectsharp.com/cs/blogs/steve/archive/2011/04/21/windows-azure-access-control-services-federation-with-facebook.aspx?CommentPosted=true#commentmessage
http://www.leastprivilege.com/AccessControlServiceV2AndFacebookIntegration.aspx
Any ideas would be appreciated.
Just checked my (working) settings. Differences I see:
I did not enter a Site Domain over at Facebook
On the ACS side, I have "Application permissions" set to "email" (not sure if you have something entered there?)