|
| 1 | +## Background |
| 2 | + |
| 3 | +This script is provided as an example for interacting with the MapSwipe backend. |
| 4 | + |
| 5 | +> [!CAUTION] |
| 6 | +> Ongoing updates to the backend might render this script **out-of-date**. |
| 7 | +
|
| 8 | +## Getting started |
| 9 | + |
| 10 | +> [!NOTE] |
| 11 | +> You will need Manager account credentials to run this script. |
| 12 | +
|
| 13 | +- Create `.env` file. |
| 14 | +- Define the following variables: |
| 15 | + - `MANAGER_URL`: URL for Manager Dashboard |
| 16 | + - `BACKEND_URL`: URL for Backend |
| 17 | + - `CSRFTOKEN_KEY`: CSRF Token Key |
| 18 | + - `ENABLE_AUTHENTICATION` |
| 19 | + - `FB_AUTH_URL`: Authentication URL |
| 20 | + - `FB_USERNAME`: Manager account username |
| 21 | + - `FB_PASSWORD`: Manager account password |
| 22 | +- For `FB_AUTH_URL`, |
| 23 | + - Sign-in on the Manager Dashboard and open Dev Console. |
| 24 | + - Look for the URL which starts with https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword |
| 25 | + <img width="1305" height="228" alt="image" src="https://github.com/user-attachments/assets/332e6673-f0e3-48c4-8420-13ef5d648f21" /> |
| 26 | + |
| 27 | +### Alpha Instance |
| 28 | + |
| 29 | +> [!CAUTION] |
| 30 | +> The alpha instance is running inside Togglecorp's domain for internal testing. |
| 31 | +
|
| 32 | +Your final `.env` for alpha instance should look like this: |
| 33 | + |
| 34 | +```dotenv |
| 35 | +MANAGER_URL=https://manager-2.mapswipe.dev.togglecorp.com |
| 36 | +BACKEND_URL=https://backend-2.mapswipe.dev.togglecorp.com |
| 37 | +CSRFTOKEN_KEY=MAPSWIPE-ALPHA-2-CSRFTOKEN |
| 38 | +
|
| 39 | +ENABLE_AUTHENTICATION=true |
| 40 | +FB_AUTH_URL=https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
| 41 | +# Your web-app login credential |
| 42 | +FB_USERNAME=me@example.com |
| 43 | +FB_PASSWORD=my-very-good-password |
| 44 | +``` |
| 45 | + |
| 46 | +### Staging Instance |
| 47 | + |
| 48 | +Your final `.env` for staging instance should look like this: |
| 49 | + |
| 50 | +```dotenv |
| 51 | +MANAGER_URL=https://managers-stage.mapswipe.org |
| 52 | +BACKEND_URL=https://backend-stage.mapswipe.org |
| 53 | +CSRFTOKEN_KEY=MAPSWIPE-STAGE-CSRFTOKEN |
| 54 | +
|
| 55 | +ENABLE_AUTHENTICATION=true |
| 56 | +FB_AUTH_URL=https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
| 57 | +# Your web-app login credential |
| 58 | +FB_USERNAME=me@example.com |
| 59 | +FB_PASSWORD=my-very-good-password |
| 60 | +``` |
| 61 | + |
| 62 | +### Production Instance |
| 63 | + |
| 64 | +Your final `.env` for production instance should look like this: |
| 65 | + |
| 66 | +```dotenv |
| 67 | +MANAGER_URL=https://managers.mapswipe.org |
| 68 | +BACKEND_URL=https://backend.mapswipe.org |
| 69 | +CSRFTOKEN_KEY=MAPSWIPE-PROD-CSRFTOKEN |
| 70 | +
|
| 71 | +ENABLE_AUTHENTICATION=false |
| 72 | +FB_AUTH_URL=https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
| 73 | +# Your web-app login credential |
| 74 | +FB_USERNAME=me@example.com |
| 75 | +FB_PASSWORD=my-very-good-password |
| 76 | +``` |
| 77 | + |
| 78 | +## Running the script |
| 79 | + |
| 80 | +Run the example script using uv |
| 81 | + |
| 82 | +```bash |
| 83 | +uv run run.py |
| 84 | +``` |
| 85 | + |
| 86 | +> [!NOTE] |
| 87 | +> To install uv, visit https://docs.astral.sh/uv/getting-started/installation/ |
0 commit comments