#!/usr/bin/env bash # Hopefully one day this will be a full featured Pleroma client. # Let's see how far we can get. :) # Get an oauth token get_oauth_token() { echo "Welcome to ${softwareName}!" echo echo "Let's get you connected to your instance." while true; do read -e -p "Enter the URL of a Pleroma instance: " instanceURL if [[ ! "${instanceURL}" =~ ^https://[a-zA-Z0-9._-]+\.[a-zA-Z]{2,}$ ]]; then echo "Invalid URL format. Please enter a valid URL that starts with 'https'." echo else break fi done # Generate a client id clientId="$(shuf -en42 -- {a..z} {A..Z} {0..9} - _)" # Fix the output from shuf so that it is a single string. clientId="${clientId//[[:space:]]/}" # Create the redirect uri, basically not needed here, but we need something redirectURI="file://$(realpath ${0})" # Create the url to get the oauth token local url="${instanceURL}/oauth/authorize?client_id=${clientId}&redirect_uri=${redirectURI}&response_type=code&scope=read%20write%20follow" echo "Please open the following url in your browser." echo "Copy the generated token, and paste it here." echo echo "${url}" echo } # Variable initialization configPath="${XDG_CONFIG_HOME:-$HOME/.config}/ratatoskr" # Path for settings, usually ~/.config/ratatoskr configFile="default.token" # The default token, eventually will support multiple accounts. softwareName="Ratatoskr" # The name of the client. # Main code starts here get_oauth_token exit 0