Skip to content

Commit

Permalink
Get access token from environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
arachnist committed Aug 4, 2024
1 parent db0886d commit 938d9d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions find_posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,9 @@ def fetch_timeline_context(timeline_posts, token, parsed_urls, seen_hosts, seen_
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):
Expand Down

0 comments on commit 938d9d7

Please sign in to comment.