Get access token from environment variable

This commit is contained in:
Ari Gato 2024-08-03 19:07:14 +02:00
parent db0886d847
commit 938d9d7d62
2 changed files with 4 additions and 1 deletions

View file

@ -136,7 +136,7 @@ Please find the list of all configuration options, including descriptions, below
Option | Required? | Notes |
|:----------------------------------------------------|-----------|:------|
|`access-token` | Yes | The access token. If using GitHub action, this needs to be provided as a Secret called `ACCESS_TOKEN`. If running as a cron job or a container, you can supply this option as array, to [fetch posts for multiple users](https://blog.thms.uk/2023/04/muli-user-support-for-fedifetcher) on your instance. |
|`access-token` | Yes | The access token. If using GitHub action, this needs to be provided as a Secret called `ACCESS_TOKEN`. If running as a cron job or a container, you can supply this option as array, to [fetch posts for multiple users](https://blog.thms.uk/2023/04/muli-user-support-for-fedifetcher) on your instance. You may also provide this option as an environment variable starting with `ACCESS_TOKEN`. To fetch posts for multiple users, define multiple environment variables, eg. `ACCESS_TOKEN_USER1=…` and `ACCESS_TOKEN_USER2=…`|
|`server`|Yes|The domain only of your mastodon server (without `https://` prefix) e.g. `mstdn.thms.uk`. |
|`home-timeline-length` | No | Provide to fetch remote replies to posts in the API-Key owner's home timeline. Determines how many posts we'll fetch replies for. Recommended value: `200`.
| `max-bookmarks` | No | Provide to fetch remote replies to any posts you have bookmarked. Determines how many of your bookmarks you want to get replies to. Recommended value: `80`. Requires an access token with `read:bookmarks` scope.

View file

@ -1488,6 +1488,9 @@ if __name__ == "__main__":
logger.critical(f"Config file {arguments.config} doesn't exist")
sys.exit(1)
if tokens := [token for envvar, token in os.environ.items() if envvar.startswith("ACCESS_TOKEN")]:
arguments.access_token = tokens
logger.info(f"Starting FediFetcher")
if(arguments.server == None or arguments.access_token == None):