I am trying to upload a file to Dropbox using their API. I have already followed the complete tutorial, but I cannot seem to figure it out.
When I execute it, I am facing the following error message along with HTTP 400 - Bad Request:
{"error": "v1_retired"}
My composer.json file is as follows:
You are getting that error message because version 1 of the Dropbox API is no longer available, as stated on the GitHub repository of the library you used. The tutorial you were using was probably outdated.
https://github.com/dropbox/dropbox-sdk-php
"Do not use this SDK. It relies on Dropbox API v1, which is obsolete."
The README advises you to use any of the provided community libraries which can be found at this page.
Related
I am getting 404 from accouts list function by using google api client.
I have already access token by using OAuth2.0.
In addition to this, I already enable the Google My Business API via https://console.developers.google.com for OAuth 2.0.
â– Here is environemnt
PHP 7.2.3
Ubuntu 18.04 LTS
google/apiclient ^2.5
The function I want to execute is as following.
https://developers.google.com/my-business/reference/rest/v4/accounts/list
I install google client libray by using composer from following link.
https://github.com/googleapis/google-api-php-client
Since google my business library is seprated, I use this program.
https://developers.google.com/my-business/samples
The steps to produce 404 is...
$client = new \Google_Client();
$client->setApplicationName("post_dev"); // app name
$client->setApprovalPrompt('force');
$client->setAccessType('offline');
$client->setAccessToken($credential);
$client->addScope("https://www.googleapis.com/auth/business.manage");
$client->addScope("https://www.googleapis.com/auth/plus.business.manage");
$gmbService = new \Google_Service_MyBusiness($client);
$results = $gmbService->accounts->listAccounts();
The variable $credential has following values.
client_id
client_secret
access_token
expires_in
refresh_token
After executing program, I am getting 404 erros like follwoing.
Google_Service_Exception[
404
]: {
"error": {
"code": 404,
"message": "Method not found.",
"errors": [
{
"message": "Method not found.",
"domain": "global",
"reason": "notFound"
}
],
"status": "NOT_FOUND"
}
}
It happens because you are trying to interact with the Google My Business API using a non-whitelisted project.
I faced the same issue. In my case, I submitted my project for whitelisting to unlock Google My Business API library.
Then, a couple weeks after that I created a new project under the same Google Cloud Platform account, just to set a more appropriate name. HERE was the root of the issue!
Even if you see the GMB library enabled at the account level, it works only at the PROJECT level. That's why you are getting 404 errors.
So, I switched everything to my original project (Consent screen settings, Oauth clients, etc)... The same on my localhost application, developed with Laravel Lumen 7.
After these couple changes, everything worked fine!
NOTE: Google allows you to whitelist 1 project per account ONLY! If your project/application were approved by Google, USE IT! Instead creating new ones.
This error has nothing to do with your access token. It cant find the method you are using. Google_Service_MyBusiness is not part of the Google api php client library.
The my Business API is unlike the other apis, it is not listed in the API directory available through the Discovery API and it requires a developer key and project acceptance into My Business. There for it cant be generated when the library generation script runs.
Im going though some channels to get that documentation page updated.
note from team Nov 1, 2018
There is a tool on the way that will help developers maintain their own version of such service classes. When it is ready and you have a project with My Business enabled you should be able to run:
export API_KEY=yourkey
bin/generate 'https://mybusiness.googleapis.com/$discovery/rest?version=v4&key=$API_KEY' generated-output
and then you can move the contents of generated-output/mybusiness-v4 anywhere you want in your include path.
That discovery URL has been known to change as new versions come out so keep and eye on https://developers.google.com/my-business/reference/rest/
Im waiting to hear the status of this.
The reason why I could not call the API is "my company already has a whitelisted project to access the Google My Business API. At this time, they are only whitelisting one project per business.". Therefore, I could not call API.
So far I'm able to use the PHP Library here - https://developers.google.com/my-business/samples/previousVersions
But the answer above was a huge help - I had EXACTLY the same issue, had "tidied up" my projects - after being granted access to the Google My Business API and seeing it available for my other projects I assumed incorrectly that my other projects would be able to use it - wrong! Very glad I found the answer here. Luckily I was able to restore the project I'd deleted, and using that one it worked straight away.
I am trying to create code for sending document for signature request using docusign API:
I already downloaded the PHP SDK
I already opened a developer sandbox account
But after filling in some info in the PHP SDK file and run, it gave me the above error.
I am guessing the error may mean that I have not gone through the steps to configure client and request authorization code.
I tried to follow the steps on that page, but the instructions are so vague and difficult to follow. I clicked on the 'use sandbox account data' on the upper right corner of the C# code, but it only asked me to log in to my account and directed me back to the same page.
I don't know where to start from there.
I need a more step-by-step instruction.
Thanks
#T. Nguyen 401 translates to an unauthorized API request and the response should say which part is wrong aka the username / password or Integrator Key is incorrect.
I really suggest using PostMan Client and / or SoapUI to validate you can get login information and see the actual error returned, as it will say Integrator Key or Username/Password in the response. PostMan or SoapUI will issue the actual API calls successfully (Demo or Prod once you have passed prod API certification) showing you the actual response without having to worry about coding typo's, properties of objects or debugging logging to see what really came back.
This allows you to learn the DocuSign API while using the PHP SDK. You did the right thing asking for help here on Stack Overflow.
I have a couple links for you to get started:
DocuSign Developer Center where you probably found the PHP SDK https://developers.docusign.com/esign-rest-api/sdk-tools
Link for info on PostMan (older version, you can get the latest one - aka Orange Rocket Man logo vs blue world, for Chrome or Mac Standalone - https://blog.grigsbyconsultingllc.com/postman-rest-client-a-google-chrome-app/
X-DocuSign-Authentication Header Q&A on StackOverflow How should the header X-DocuSign-Authentication be used for REST and SOAP?
I like the concept of the DocuSign API explorer to start with, sad part is it doesn't work against prod, so you still have to use something else when you move from demo to prod.
Best of Luck and Enjoy your DocuSign API journey!
You can set $config->setDebug(true) in dev environment and have all the errors displayed.
to fetch error use this
try{
//send request
}
catch (DocuSign\eSign\ApiException $ex){
print_R($ex); //<--- print normal readeble error
echo "Exception: " . $ex->getMessage() . "\n";
}
I am having an issue sending requests from our PHP application to the OneDrive SDK.
I am using the following package to integrate our application with OneDrive:
https://github.com/krizalys/onedrive-php-sdk
It has been working perfectly fine for months then all of a sudden this morning it started responding with an SSL error:
SSL read: error:00000000:lib(0):func(0):reason(0), errno 104
I have tried to fix it all sorts of ways:
Updating all the dependencies within composer
Updating curl, openssl and php7.0-curl on the server (was already latest versions)
Creating a new OneDrive account to test to see if the problem persists (which is does)
When I created a new OneDrive account, the demo that is available through the GitHub package I linked earlier worked, but as soon as I started sending requests from our application it is now returning the same error as above.
I have been checking the status of OneDrive through various websites and social media but nothing has caught my attention with relation to the problem I am having.
We are using a basic Microsoft account, not a business one, I am not sure if maybe Microsoft has cottoned on to us using their SDK for business purposes and maybe blocked our application from sending requests, but I am unable to find any documentation online that relates to business vs non business SDK usage.
I have also been trying to find a support/contact page so I could contact Microsoft to confirm my theory above but I was unable to, so I am here hoping that my question could be answered.
Any help would be greatly appreciated.
I keep getting the following error when I try to use the Mailchimp OAUTH2 sample app (PHP).
For your reference, here's their github repo: https://github.com/mailchimp/OAuth2-sample-apps
However, my client id and client secret are correct (have copied and pasted them multiple times).
Complete Failure!: redirect_uri_mismatch
This likely means that you have entered a bad client_id or client_secret or you are being awesome and checking to see this failure occur.
Try Again?
If it helps, I'm using the Yii 2 framework.
I am using the PHP version of the Google Glass Developer Kit. Setup everything per the sample code instructions. API/credentials are all fine, account billing is setup, have added the Mirror API to the project, but after I permission the application, I get the following Error:
An error ocurred: Error calling POST
https://www.googleapis.com/mirror/v1/timeline?key=xxxxxx
(403) Access Not Configured.
Please use Google Developers Console to activate the API for your project.
I have added the Mirror API and have Billing active and setup so have no idea why i am getting the error message. Testing the app via the Glass Explorer works just fine.
Google APIs have been known to misbehave when you provide both OAuth2 credentials and an API Key. Also since you have to use OAuth2 to access the Mirror API, the key=xxxxx isn't necessary anyway.
If you are using the Google APIs Client Library for PHP you can simply remove the following line from your code:
$client->setDeveloperKey($key);
Not entirely sure if this causes your issue, but I have come across similar issues in other Google APIs.
In Google API console for your project (https://code.google.com/apis/console/)
Make sure that your "Public API access" or "Key for server application" has allowed the IP address of your server.
Also make sure you have the proper "Redirect URIs", if you get refused, look at your php logs, I had this:
PHP Fatal error: Uncaught exception 'Google_ServiceException' with message 'Error calling GET https://www.googleapis.com/mirror/v1/timeline?maxResults=3&key=: (403) Access Not Configured. Please use Google Developers Console to activate the API for your project.'
use your $base_url + /oauth2callback.php to find out what the correct Redirect URI is.
I managed to solve the issue by adding the IP address and REDIRECT URIs and it runs both on my local machine and on the server. (same code, same key)
PS: I want to thank Scarygami, disabling the $client->setDeveloperKey($key); helped me find the solution.