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

Commit

Permalink
authenticate using token
Browse files Browse the repository at this point in the history
  • Loading branch information
rodriguestiago0 committed Jul 17, 2024
1 parent 582cbdc commit dc181d8
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 27 deletions.
12 changes: 4 additions & 8 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# Your Tink keys, which can be found in the Tink Dashboard.
# https://tink.com/

TINK_CLIENT_ID=
TINK_CLIENT_SECRET=
TINK_USER_ID=
TINK_ACTOR_ID=
EDENRED_USERNAME=
EDENRED_PASSWORD=
EDENRED_TOKEN=

# Comma-separated.
# both need to have the same length
TINK_ACCOUNT_MAP=
EDENRED_ACCOUNT_MAP=
ACTUAL_ACCOUNT_MAP=

ACTUAL_SERVER_URL="server url"
Expand Down
8 changes: 4 additions & 4 deletions README.Docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ services:
- PUID=1003
- PGID=100
- TZ=Europe/Lisbon
- EDENRED_USERNAME=
- EDENRED_PASSWORD=
#- EDENRED_USERNAME= deprecated for now
#- EDENRED_PASSWORD= deprecated for now
- EDENRED_TOKEN=
- 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 @@ -27,8 +28,7 @@ services:

```
docker run -d --name myedenredactual \
- e 'EDENRED_USERNAME=' \
- e 'EDENRED_PASSWORD=' \
- e 'EDENRED_TOKEN=' \
- e 'EDENRED_ACCOUNT_MAP=' \
- e 'ACTUAL_ACCOUNT_MAP=' \
- e 'ACTUAL_SERVER_URL= ' \
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ You need to provide your username and password and specified what the cadence yo
- Clone this repo!
- Install dependencies: `npm ci`
- Copy `.sample.env` to `.env` and fill in the blanks
- Run `check`: `node index.js check`, this will check the balance between your Actual Budget account and the accounts setup on tink
- Run `check`: `node index.js check`, this will check the balance between your Actual Budget account
- Run `import`: `node index.js import`, this will import all transactions to Actual

## Some things worth noting

The intial transaction import does not have a starting balance, so you will need to manually add that to Actual Budget.

You need to manually create the accounts inside Actual, and then map them to the accounts you setup in Tink.
You need to manually create the accounts inside Actual, and then map them to the My Edenred accounts.

## Commands

Expand Down
10 changes: 6 additions & 4 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ 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_USERNAME = process.env.EDENRED_USERNAME || "";
//const EDENRED_PASSWORD = process.env.EDENRED_PASSWORD || "";
const EDENRED_TOKEN = process.env.EDENRED_TOKEN || "";
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 @@ -32,8 +33,9 @@ function getAppConfigFromEnv() {
const appConfig = {
APP_PORT,
APP_URL,
EDENRED_USERNAME,
EDENRED_PASSWORD,
//EDENRED_USERNAME,
//EDENRED_PASSWORD,
EDENRED_TOKEN,
EDENRED_ACCOUNT_MAP,
ACTUAL_ACCOUNT_MAPPING,
EDENRED_ACCOUNT_MAPPING,
Expand Down
13 changes: 6 additions & 7 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
version: '3'
services:
actual_server:
container_name: tinkactual
image: docker.io/rodriguestiago0/tinkactual
container_name: myedenredactual
image: docker.io/rodriguestiago0/myedenredactual
ports:
- '5006:5006'
environment:
- PUID=1003
- PGID=100
- TZ=Europe/Lisbon
- TINK_CLIENT_ID=
- TINK_CLIENT_SECRET=
- TINK_USER_ID=
- TINK_ACTOR_ID=
- TINK_ACCOUNT_MAP= #comma separated vlue (Both TINK_ACCOUNT_MAP and ACTUAL_ACCOUNT_MAP need to have the same size)
#- EDENRED_USERNAME= deprecated for now
#- EDENRED_PASSWORD=deprecated for now
- EDENRED_TOKEN=
- 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=
- ACTUAL_SERVER_PASSWORD=
Expand Down
4 changes: 2 additions & 2 deletions edenredService.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const getAllTransactions = async (token, accountId) => {
}

async function getTransactions(accountId) {
authorizationToken = await authenticate()
transactions = await getAllTransactions(authorizationToken, accountId)
//authorizationToken = await authenticate()
transactions = await getAllTransactions(appConfig.EDENRED_TOKEN, accountId)
parsedTransactions = []
transactions.forEach(transaction => {
transactionID = crypto.createHash('sha256').update(transaction.transactionName+transaction.transactionDate+transaction.amount).digest('hex');
Expand Down

0 comments on commit dc181d8

Please sign in to comment.