how to use third party components? for example google api

thcom
Backer | 94
+
0
-

hi, i can work with nette, but i never used third party component

can yopu please help me, where should i put the files and where setup to use them

many thans

Tomas Holy

thcom
Backer | 94
+
0
-

hi, thank you

i learn to use install new nete project with composer
with
cd /var/www
composer create-project nette/web-project my_new_project

i can add google api to my_new_project
cd /var/www/my_new_project
composer require google/apiclient

now the application seem to be working

but another question, where is the right place to store
files like credentials.json and token.json

i choose /app/config/google

is it OK ?

dkorpar
Member | 135
+
0
-

That's up to you, that location sounds good. Nette won't force you to put that to any specific folder and nette doesn't have anything to do with google api, but app/config/google sounds good and it's compliant with nette framework infrastructure.

thcom
Backer | 94
+
0
-

thank you, please help me little
how to tell to nette, where i have these files

now i use crazzy solution

$client->setAuthConfig('/var/www/nga/app/config/google/credentials.json');
$tokenPath = '/var/www/nga/app/config/google/token.json';

it is working, but i feel it is not good

shoudl i use nette configurator ?
but how, i can find description, which i understand

many thanks

CZechBoY
Member | 3608
+
0
-

What exactly are you implementing? Google Auth?
You can create nette/di extension which will hold your configuration and pass it to some service after application start for example.

thcom
Backer | 94
+
0
-

I need to read some data from google sheet document

I try to look on di extension

Many thanks

David Matějka
Moderator | 6445
+
0
-

it should be enough to register the client as a service and configure it in your config.neon:

services:
	googleApiClient:
		class: Google_Client
		setup:
			- setAuthConfig(%appDir%/config/google/credentials.json)