diff --git a/README.Docker.md b/README.Docker.md index eb02f7b..0733278 100644 --- a/README.Docker.md +++ b/README.Docker.md @@ -14,9 +14,8 @@ services: - PUID=1003 - PGID=100 - TZ=Europe/Lisbon - #- EDENRED_USERNAME= deprecated for now - #- EDENRED_PASSWORD= deprecated for now - - EDENRED_TOKEN= + - EDENRED_USERNAME= + - EDENRED_PIN= - EDENRED_ACCOUNT_MAP=comma separated vlue (Both EDENRED_ACCOUNT_MAP and ACTUAL_ACCOUNT_MAP need to have the same size) - ACTUAL_ACCOUNT_MAP=#comma separated vlue - ACTUAL_SERVER_URL= @@ -28,7 +27,8 @@ services: ``` docker run -d --name myedenredactual \ - - e 'EDENRED_TOKEN=' \ + - e 'EDENRED_USERNAME=' \ + - e 'EDENRED_PIN=' \ - e 'EDENRED_ACCOUNT_MAP=' \ - e 'ACTUAL_ACCOUNT_MAP=' \ - e 'ACTUAL_SERVER_URL= ' \ diff --git a/README.md b/README.md index 5b5c97d..6428a2c 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ You need to provide your username and password and specified what the cadence yo **Note**: Pending transaction are being imported as cleared. If the transaction is deleted after you need to delete manally from the actual budget. +# Get User ID +User ID now is a `GUID` and not your email address. + +For `IOS` I used an app called `Proxyman` and checked the request to get the `UserID`. The `PIN` is your app `PIN`. ## Setup diff --git a/config.js b/config.js index f86f531..48664d7 100644 --- a/config.js +++ b/config.js @@ -9,9 +9,8 @@ const APP_PORT = process.env.APP_PORT || 3000; const APP_URL = process.env.APP_URL || "http://localhost" -//const EDENRED_USERNAME = process.env.EDENRED_USERNAME || ""; -//const EDENRED_PASSWORD = process.env.EDENRED_PASSWORD || ""; -const EDENRED_TOKEN = process.env.EDENRED_TOKEN || ""; +const EDENRED_USERNAME = process.env.EDENRED_USERNAME || ""; +const EDENRED_PIN = process.env.EDENRED_PIN || ""; const EDENRED_ACCOUNT_MAP = process.env.EDENRED_ACCOUNT_MAP || ""; const ACTUAL_ACCOUNT_MAP = process.env.ACTUAL_ACCOUNT_MAP || ""; const CRON_EXPRESSION = process.env.CRON_EXPRESSION || ""; @@ -33,9 +32,8 @@ function getAppConfigFromEnv() { const appConfig = { APP_PORT, APP_URL, - //EDENRED_USERNAME, - //EDENRED_PASSWORD, - EDENRED_TOKEN, + EDENRED_USERNAME, + EDENRED_PIN, EDENRED_ACCOUNT_MAP, ACTUAL_ACCOUNT_MAPPING, EDENRED_ACCOUNT_MAPPING, diff --git a/edenredService.js b/edenredService.js index 4802d83..05b3924 100644 --- a/edenredService.js +++ b/edenredService.js @@ -7,14 +7,16 @@ const appConfig = getAppConfigFromEnv(); const authenticate = async () => { u = { userId: appConfig.EDENRED_USERNAME, - password: appConfig.EDENRED_PASSWORD + password: appConfig.EDENRED_PIN, + appType: "IOS", + appVersion: "4.1.0" }; - const token = await fetch('https://www.myedenred.pt/edenred-customer/v2/authenticate/default?appVersion=1.0&appType=PORTAL&channel=WEB', { + const token = await fetch('https://www.myedenred.pt/edenred-customer/v2/authenticate/pin?appVersion=4.1.0&appType=IOS&channel=MOBILE', { method: 'POST', body: JSON.stringify(u), headers: { 'Content-type': 'application/json', - 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36', + 'User-Agent': 'EdenRED/3748 CFNetwork/1496.0.7 Darwin/23.5.0', }, }) .then((response) => response.json()) @@ -46,8 +48,8 @@ const getAllTransactions = async (token, accountId) => { } async function getTransactions(accountId) { - //authorizationToken = await authenticate() - transactions = await getAllTransactions(appConfig.EDENRED_TOKEN, accountId) + authorizationToken = await authenticate() + transactions = await getAllTransactions(authorizationToken, accountId) parsedTransactions = [] transactions.forEach(transaction => { transactionID = crypto.createHash('sha256').update(transaction.transactionName+transaction.transactionDate+transaction.amount).digest('hex');