wesselt / bunq2ynab

Upload bunq transactions to ynab
Other
72 stars 18 forks source link

Add script to generate Bunq token with oauth #47

Closed mvgijssel closed 10 months ago

mvgijssel commented 10 months ago

ref #25

ref https://github.com/mvgijssel/setup/issues/451

Test plan

  1. Following this guide create a private Oauth application inside of Bunq like so

image

  1. Set the redirect url to http://localhost:3000 on the Authentication screen (without a trailing slash, otherwise you'll get errors)

  2. Copy the Oauth Client ID and OAuth Client Secret from the Authentication screen

image

  1. Run python3 generate_oauth_token.py --oauth-client-id "<<paste Oauth Client ID>>" --oauth-client-secret "<<paste OAuth Client Secret>>" by pasting what you copied from step 3 (without the << and >>).

  2. A browser window opens with a QR code for you to accept the connection

  3. On your phone accept the connection and make sure to select all accounts you want to sync with bunq2ynab

  4. Your access token will be printed inside the browser. You can use this instead like you would use a regular token, but with less permissions 🎉

TODO

wesselt commented 10 months ago

That took some tries, but it worked in the end. I got the client ID and secret from the app, Profile > Developers > OAuth. The redirect URL had to match exactly (I initially added a trailing slash in the app.) It's now running without a developer token, which feels much safer!

Your todo list looks good to me. I like displaying the code in the browser. Some suggestions:

mvgijssel commented 10 months ago

The redirect URL had to match exactly

I can update the test plan to reflect that so it can later be used in the README

Instead of using environment variables, consider using the lib/config.py functions, which read command line parameters and the config.json file

Yeah agreed, that's a nicer interface!

Why reformat lib/bunq_api.py and list_user.py?

Editor did it automatically, will revert to prevent unnecessary changes!

The listening web server should probably bind to localhost only, not any other adapters

Yeah I think so as well!

wesselt commented 10 months ago

Als ik een diff met de huidige master branch doe zie ik een aantal onbedoelde verschillen. Zal te maken hebben met de branch "intervals" die ik gisteren gemerged heb. Bunq lijkt geen callbacks meer te sturen op een andere poort dan 443, ik heb daarop wat configurabel gemaakt.

Een rebase helpt wellicht.

mvgijssel commented 10 months ago

Heb gemerged met master, de TODOs gedaan en dingen een beetje opgeruimd. Volgens mij moet het nu goed zijn!

wesselt commented 10 months ago

Looking good! Feels great not to have a developer token out there. Thanks!