From 3ea89fdf821502d9422205a3cf3ee68525bcb3aa Mon Sep 17 00:00:00 2001 From: arne Date: Fri, 3 Feb 2023 09:58:24 +0100 Subject: [PATCH] Add section on access token to README --- README.md | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0563619..c7aed08 100644 --- a/README.md +++ b/README.md @@ -5,15 +5,32 @@ This is a small program that posts an image from a given folder every time you c ## Setup - [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 - 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 You can call it like so: -``` -MASTODON_INSTANCE_URL=... MASTODON_ACCESS_TOKEN=... deno run --allow-env --allow-net --allow-write --allow-read main.ts [folder] +``` bash +# 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.