From b87025a0a86311fee4b874d8cdaa00c38a3de2f1 Mon Sep 17 00:00:00 2001 From: Horea Porutiu Date: Wed, 4 Sep 2024 12:55:48 +0200 Subject: [PATCH] Update examples/python-webhooks/README.md Co-authored-by: Ruslan <152289003+ruslan-kotowski@users.noreply.github.com> --- examples/python-webhooks/README.md | 46 ++++-------------------------- 1 file changed, 6 insertions(+), 40 deletions(-) diff --git a/examples/python-webhooks/README.md b/examples/python-webhooks/README.md index 5f60ec590..e99f487af 100644 --- a/examples/python-webhooks/README.md +++ b/examples/python-webhooks/README.md @@ -45,49 +45,15 @@ https://github.com/user-attachments/assets/0ccffb46-daab-4fc9-8ff8-f5720237f75a # 🏃🏽‍♂️ Run the app locally -0. It is recommended to use a virtual env to run this app example. Go to where you .venv is and then activate it with the - `source ./bin/activate` command. Read more about venvs [here](https://docs.python.org/3/library/venv.html). +> It is recommended to use a virtual environment to run this app example. Go to where you `.venv` is located and then run `source ./bin/activate` command. Read more about venvs [here](https://docs.python.org/3/library/venv.html). -1. Create a new Miro app on [developers.miro.com](https://developers.miro.com/). This will take you to the app settings page. There you - will find the `MIRO_CLIENT_ID` and `MIRO_CLIENT_SECRET` to be added to your `.env` file. Ensure that your app URL is `http://localhost:5000` since that is what port Flask will be running on. Ensure that `boards:read` scope is checked, - and then go ahead and install the app on your developer team. You will get an **access token** which you will need later to - authenticate the creation of your webhook subscription. +1. Create a new Miro app on [developers.miro.com](https://developers.miro.com/). This will take you to the app settings page. There you will find the `MIRO_CLIENT_ID` and `MIRO_CLIENT_SECRET` to be added to your `.env` file. Ensure that your app URL is `http://localhost:5000` since that is what port Flask will be running on. + + - Ensure the `boards:read` scope is selected. + - Install the app on your developer team. You will get an **access token** which you will need later to authenticate the creation of your webhook subscription. -2. In a new terminal session, run: +2. In a new terminal window, run: -``` -ngrok http 5000 -``` - -This will output something like this: - -``` -Forwarding https: -> http://localhost:5000 -``` - -The `https:` is your `MIRO_REDIRECT_URL` to be used in the `.env` file and then later when calling the API to create a webhook subscription. - -3. Rename the `.sample.env` file to `.env` and then add in your `MIRO_CLIENT_ID` and `MIRO_CLIENT_SECRET` from your [developers.miro.com](https://developers.miro.com/) app settings page. Use the `forwarding URL` from the previous step for the `MIRO_REDIRECT_URL` in the .env file. Save the file as `.env` with your new variables. - -4. Run `pip install -r requirements.txt` to install dependencies. - -5. In a separate terminal from the ngrok terminal (leave ngrok running) go to `app-examples/examples/python-webhooks` directiory. Run `flask --app app run` to start the server. Your server should be running on port 5000. - -6. Go to your developer team, and open the board you want to receive webhook events for. - -7. In a separate browser tab, open up the API Exporer for the [Create Webhook Subscription endpoint](https://developers.miro.com/reference/create-board-subscription). - -8. Provide the following information in the API Explorer: - -> **Access Token**: Once you get the access token after installing your app on a developer team (from step 4 above), you can add the access token to the Authorization section of the API reference page. -> -> **boardId:** Get the board ID of the board you want to receive notifications for. This board should be in the same team where you installed the app. You can find board ID in the URL when you go to your board: https://miro.com/app/board/. -> -> **callbackUrl:** This is the URL where you will receive events. It should be the same as `MIRO_REDIRECT_URL` in `.env`. - -9. Select Try It! to run the API request right from the browser. If you get a 201 response, you are ready to receive events! - -10. Next, go to to the same board which you referenced in the request above, and create a sticky. You should now receive a webhook event! Great job! You've just learned how to get started with Miro's webhooks with Python 🎉. # 🗂️ Folder structure