From 7948c962f35434c9b2c71879404279cc66ef1b14 Mon Sep 17 00:00:00 2001 From: Hugo <hnouts.dev@gmail.com> Date: Wed, 6 Jan 2021 17:41:03 +0100 Subject: [PATCH] troubleshooting - refresh token --- docs/ecolyo/konnectors/enedis.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/ecolyo/konnectors/enedis.md b/docs/ecolyo/konnectors/enedis.md index 4c238e1..34669c2 100644 --- a/docs/ecolyo/konnectors/enedis.md +++ b/docs/ecolyo/konnectors/enedis.md @@ -81,3 +81,21 @@ For more information about Datahub-Enedis API, checkout the [Datahub documentati | buildDataFromKey | Format an entry for DB storage using key and value. For year doctype: key = "YYYY". For month doctype: key = "YYYY-MM" | | isHistoryLoaded | Function checking if the history is loaded | | resetInProgressAggregatedData | Function handling special case.The temporary aggregated data need to be remove in order for the most recent one te be saved. Ex for com.grandlyon.enedis.year : `{ load: 76.712, year: 2020, ... }` need to be replace by `{ load: 82.212, year: 2020, ... }` after enedis data reprocess | + +## Troubleshooting when asking for refresh token + +When a token expires, the konnector will encounter an error when fetching user data, leading to a refresh token request. + +Since refresh token requests restart the Konnector, it was decided to add the ```usage_point_id``` into the start fields when asking for a refresh token (see line 97). + +!!! info "restart to refresh token" + Line 85: ```await cozyClient.fetchJSON( + 'POST', + `/accounts/enedisgrandlyon/${accountId}/refresh` + )``` + + Line 97: ```fields.usage_point_id = usage_point_id``` + + Line 98: ```return start(fields, cozyParameters, false)``` + +In fact the usage_point_id still remains in the account collection, but on restart, the konnector loses ```this._account``` context leading to an error when searching for usage_point_id in account. \ No newline at end of file -- GitLab