2

I have copied the code in their documentation on this site: here.

I have changed the JSON on these below. I have generated a fresh files on API on the composer, but I am still having some issues. I'm not sure what have I done wrong. Does this mean their API is way too buggy?

Here is the demo link: demo

define('APPLICATION_NAME', 'Ashima');
define('CREDENTIALS_PATH', '/mycredentials.json');
define('CLIENT_SECRET_PATH', __DIR__ .'/mysecret.apps.googleusercontent.com.json');

Error:

Fatal error: Uncaught exception 'InvalidArgumentException' with message 'file does not exist' in /var/www/mysite/googleapi2/vendor/google/apiclient/src/Google/Client.php:839 Stack trace: #0 /var/www/mysite/googleapi2/quick.php(32): Google_Client->setAuthConfig('/var/www/payrol...') #1 /var/www/mysite/googleapi2/quick.php(80): getClient() #2 {main} thrown in /var/www/mysite/googleapi2/vendor/google/apiclient/src/Google/Client.php on line 839

11
  • i got these error too , i am hoping anybody helps you on these Commented Sep 16, 2016 at 6:25
  • i'm not sure if you can select the right path on your CLIENt secret path in the wrong way it will bug? Commented Sep 16, 2016 at 6:33
  • have you tried this one? github.com/google/google-api-php-client Commented Sep 16, 2016 at 6:35
  • 1
    wild guess something is wrong with your path it cant find your credentials files. Commented Sep 16, 2016 at 6:49
  • 1
    i have added here i think this is a good sign? Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Invalid token format' in Commented Sep 16, 2016 at 6:54

2 Answers 2

2

The CLIENT_SECRET_PATH is not the CLIENT ID JSON file.

After creating the OAuth 2.0 client IDs for the project from below link you need to create a service account keys, to do this follow those steps:

  1. From here https://console.developers.google.com/apis/credentials
  2. Click Create Credentials
  3. Choose service account keys
  4. Select the service account and keep JSON checked.
Sign up to request clarification or add additional context in comments.

Comments

0

Here I'm:

1) "CREDENTIALS_PATH" should point to a nonexistent file (in a writable path)

2) "CLIENT_SECRET_PATH" should point to the "ID client OAuth 2.0" credential file, created and downloaded from the Google Console in the Api Credential section.

For a server side php script, like yours, pay attention when creating the "ID client OAuth 2.0" record: on the creation wizard, you should select "other" type of application and not the "web" type.

Regards

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.