Skip to content

Commit

Permalink
Update examples/python-webhooks/README.md
Browse files Browse the repository at this point in the history
Co-authored-by: Ruslan <[email protected]>
  • Loading branch information
horeaporutiu and ruslan-kotowski authored Sep 4, 2024
1 parent 55d30e5 commit b87025a
Showing 1 changed file with 6 additions and 40 deletions.
46 changes: 6 additions & 40 deletions examples/python-webhooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,49 +45,15 @@ https://github.com/user-attachments/assets/0ccffb46-daab-4fc9-8ff8-f5720237f75a
# 🏃🏽‍♂️ Run the app locally <a name="run"></a>

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:<your-ngrok-url> -> http://localhost:5000
```

The `https:<your-ngrok-url>` 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/<boardId>.
>
> **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 <a name="folder"></a>

Expand Down

0 comments on commit b87025a

Please sign in to comment.