Add section on access token to README

This commit is contained in:
arne 2023-02-03 09:58:24 +01:00
commit 3ea89fdf82

View file

@ -5,15 +5,32 @@ This is a small program that posts an image from a given folder every time you c
## Setup ## Setup
- [Install deno](https://deno.land/manual@v1.30.1/getting_started/installation) - [Install deno](https://deno.land/manual@v1.30.1/getting_started/installation)
- Create an account on a bot-friendly mastodon instance and obtain an access token (see below)
- Create a folder somewhere on your computer - Create a folder somewhere on your computer
- Fill the folder with images you'd like to post - Fill the folder with images you'd like to post
## Obtaining an access token
An access token is required for this bot to log into an account and act on behalf of it, to upload images and create new posts. To set it up, go to the "New application" page on your mastodon instance (for example https://botsin.space/settings/applications/new).
- Give your bot a name
- Scroll down to "Scopes"; you can uncheck everything and check only `write:media` and `write:posts`.
- Click submit. You will be redirected to https://botsin.space/settings/applications
- Click on the application you just created
- Copy the value in the row "your access token". It will be a sequence of letters and numbers that looks like `K3g57Yv4-wsg8I78VzegJIowGr-AS1HWmXO2tD9MmPu`.
Anybody with this access token can use the account to upload media and write posts, so take care to not publish it anywhere where a lot of people have access to it.
## Usage ## Usage
You can call it like so: You can call it like so:
``` ``` bash
MASTODON_INSTANCE_URL=... MASTODON_ACCESS_TOKEN=... deno run --allow-env --allow-net --allow-write --allow-read main.ts [folder] # for example MASTODON_INSTANCE_URL=https://botsin.space
export MASTODON_INSTANCE_URL=...
# for example MASTODON_ACCESS_TOKEN=K3g57Yv4-wsg8I78VzegJIowGr-AS1HWmXO2tD9MmPu
export MASTODON_ACCESS_TOKEN=...
deno run --allow-env --allow-net --allow-write --allow-read main.ts [folder]
``` ```
It is best if you specify `folder` as an `/absolute/path/like/so`. If you leave out `folder` when calling the script, it will try to look for a `posts` directory inside the folder where the script is located. It is best if you specify `folder` as an `/absolute/path/like/so`. You can also a `folder` when calling the script, it will try to look for a `posts` directory inside the folder where the script is located.