how to use third party components ? for example google api

3 months ago

thcom
Member | 29
+
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

3 months ago

thcom
Member | 29
+
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 ?

3 months ago

dkorpar
Member | 67
+
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.

3 months ago

thcom
Member | 29
+
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

3 months ago

CZechBoY
Member | 3377
+
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.

3 months ago

thcom
Member | 29
+
0
-

I need to read some data from google sheet document

I try to look on di extension

Many thanks

3 months ago

David Matějka
Moderator | 5933
+
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)