Store the access token in an environment variable instead of a file. Not sure which language are you using but for my bot I have this Python code to retrieve the token which is stored in the MASTODON_TOKEN environment var.
TOKEN_ENVIRON_VAR = 'MASTODON_TOKEN'
def get_auth_token():
'''Fetches the auth token from the env var.'''
try:
token = os.environ[TOKEN_ENVIRON_VAR].strip()
if not token:
raise ValueError()
return token
except Exception as e:
logging.error('Unable to get the auth token for Mastodon')
logging.error(e, exc_info=True)
sys.exit(-1)