:construction: Section under Construction :construction:
:construction: Section under Construction :construction:
This konnector fetches consumptions measures from Grdf Adict API. This is an Oauth Konnector, meaning the authentification performed to access all data is made following an Oauth2 protocol.
This konnector fetches consumptions measures from Grdf Adict API. This is an Oauth Konnector, meaning the authentification performed to access all data is made following an Oauth2 protocol.
You can clone the project [here](https://forge.grandlyon.com/web-et-numerique/llle_project/grdf-adict-konnector).
You can clone the project [here](https://forge.grandlyon.com/web-et-numerique/llle_project/grdf-adict-konnector).
...
@@ -10,7 +10,7 @@ You should also check Cozy's official documentations for konnectors :
...
@@ -10,7 +10,7 @@ You should also check Cozy's official documentations for konnectors :
## Grdf Adict Konnector
## Grdf Adict Konnector
The Oauth protocol does not take place in the konnector code, therefore it is also important to take a look at the [proxy](../proxy/description.md) to fully understand all the interactions that will be told below.
The Oauth protocol does not take place in the konnector code, therefore it is also important to take a look at the [proxy](../../proxy/description.md) to fully understand all the interactions that will be told below.
All the actions performed by the stack are targetted from pre-registered paramaters, here is the list of all parameters needed by the stack to perform the Oauth protocol and allow the konnector to fetch data.
All the actions performed by the stack are targetted from pre-registered paramaters, here is the list of all parameters needed by the stack to perform the Oauth protocol and allow the konnector to fetch data.
...
@@ -18,28 +18,27 @@ All the actions performed by the stack are targetted from pre-registered paramat
...
@@ -18,28 +18,27 @@ All the actions performed by the stack are targetted from pre-registered paramat
On its first launch, following the Oauth Client Connect authentification.
On its first launch, following the Oauth Client Connect authentification.
- The cozy stack calls the **authentification_endpoint** and start the oauth protocol, see [proxy doc](../proxy/description.md).
- The cozy stack calls the **authentification_endpoint** and start the oauth protocol, see [proxy doc](../../proxy/description.md).
- The account has now an access_token and an id_token from the oauth call
- The account has now an access_token and an id_token from the oauth call
!!! info ""
!!! info ""
id_token is only given when requesting the token endpoint in *authorization_code* grant_type.
id_token is only given when requesting the token endpoint in _authorization_code_ grant_type.
This token holds several meta datas, including the pce_id (id of user's meter) that will be needed further to fetch user's datas.
This token holds several meta datas, including the pce_id (id of user's meter) that will be needed further to fetch user's datas.
- Konnector starts, fails to find a pce_id in database on first launch therefore decodes the id_token to store the pce_id in db (see [addData](https://docs.cozy.io/en/cozy-konnector-libs/api/#adddata_1)).
- Konnector starts, fails to find a pce_id in database on first launch therefore decodes the id_token to store the pce_id in db (see [addData](https://docs.cozy.io/en/cozy-konnector-libs/api/#adddata_1)).
- Konnector restarts, this time knowing a pce_id, it fails to fetch datas because the access_token from oauth call has a reduced scope (only scoping for meta data requests).
- Konnector restarts, this time knowing a pce_id, it fails to fetch datas because the access_token from oauth call has a reduced scope (only scoping for meta data requests).
- Konnector launches a refresh call, the proxy knows to answer it with a *client_credentials* grant_type call to grdf /access_token.
- Konnector launches a refresh call, the proxy knows to answer it with a _client_credentials_ grant_type call to grdf /access_token.
- Konnector restarts with everyting needed in database to fetch datas and store them in couchdb.
- Konnector restarts with everyting needed in database to fetch datas and store them in couchdb.
- Further jobs will not need to change scope again and will only ask for refresh tokens.
- Further jobs will not need to change scope again and will only ask for refresh tokens.
### Flow summarized
### Flow summarized


!!! info "to do"
!!! info "to do"
:construction: Request PCE's frequency :construction:
:construction: Request PCE's frequency :construction:
Grdf owns different type of meters, some are read twice a year (every six months therefore called 6M), others are 1M or 1D
Grdf owns different type of meters, some are read twice a year (every six months therefore called 6M), others are 1M or 1D
## Launch on standalone
## Launch on standalone
...
@@ -51,9 +50,9 @@ Build the konnector with `yarn build`.
...
@@ -51,9 +50,9 @@ Build the konnector with `yarn build`.