Skip to content
This repository has been archived by the owner on Jan 5, 2025. It is now read-only.

Commit

Permalink
Fix issue with authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
rodriguestiago0 committed Jul 23, 2024
1 parent dc181d8 commit e658d79
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
8 changes: 4 additions & 4 deletions README.Docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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= ' \
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 4 additions & 6 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || "";
Expand All @@ -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,
Expand Down
12 changes: 7 additions & 5 deletions edenredService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit e658d79

Please sign in to comment.