Skip to content

Jakayus/StrayToots

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StrayToots

This Project creates a Mastodon Client for the Apple Watch that allows for simple Toot activities ("Favourite", "Boost", "Bookmark".)

Simple Toot interaction occurs on the Watch App, while settings and signing in happens on the companion iPhone app.

(Please note that the objectives have not been implemented yet.).

App objectives:

iPhone app:

  • Log into an instance

Watch App:

  • View user's timelines on instance
  • "Favourite" a Toot
  • "Boost" a Toot
  • "Bookmark" a Toot

Screenshots (unfinished and in super early stages, but here's what exists so far)

Watch Screenshot 1 Watch Screenshot 2

Setup

A Mastodon Access Token is required before running the project. This token is placed into a plist file in order to run.

Mastodon Access Token

I personally used Postman for getting the tokens, but any API inspector tool will do. Before getting an access token, you must first get a client ID and a client access key from Mastodon. Steps are listed below, with additional notes on doing it through Postman.

Request a ClientID and ClientSecret

  • Copy and paste the curl command from the above link into your desired API inspection tool (in Postman: After creating a workspace, click "Import" on the top left near the workspace name, and copy/paste the curl command into the text field that comes up. Postman will create a POST command for you.)
  • Replace "mastodon.example" with your desired mastodon instance
  • Send your POST command using the API inspector tool used
  • Save off the contents somewhere for future use. Most important will be the client_id and the client_secret

Use the Authorization GET Request to get the Authorizaton Code

  • Click the link above and copy/paste the https command somewhere you can edit it
  • replace "mastodon.exmaple" with your mastodon instance and "CLIENT_ID" with your client id
  • remove the line endings so that the command is one long string
  • copy/paste this string into your browser
  • it will bring you to your instance login page. Log into your account
  • will ask you to grant access based upon the request made
  • copy the authorization code and store it somewhere safe

Use the Authorization Code to get the Access Token

  • Click the link above to get the needed curl command and place it into an API inspector tool (in Postman: use "Import" like in the previous section")
  • Replace client_id, client_secret, and code with your client_id, client_secret, and authorization_code
  • Execute the POST command using the API inspector tool and save off the results
  • The results include your Access Token

Test your Authorization Token

Test your token before jumping into Xcode - it can save a lot of time.

  • Copy/paste the below curl command into your API inspector tool

curl
-H 'Authorization: Bearer our_access_token_here'
https://mastodon.example/api/v1/accounts/verify_credentials

  • replace "mastodon.example" with your mastodon instance
  • replace "our_access_token_here" with your access token within the header section of the API tool used. (Note - make sure there is a space between "Bearer" and your access token)
  • You should see your credentials show up

Running the Project

The above steps provide a method to getting an access code. Please also refer to the Mastodon API documentation if more information is needed.

The project currently uses a plist file that is used to place the access token needed for API calls. You will be creating a new plist file with the access code just generated. This should allow you to access your instance.

The following steps are needed to successfully run the app:

  1. Clone, Fork, or Download the project for personal use
  2. Create a copy of the "TokensExample.plist" file and rename it to "Tokens.plist" (spelling is important so that you don't accidentally commit your token to the repo)
  3. Copy/Paste your personal Access Token to the "Tokens.plist" file
  4. Navigate to the "MastodonNetworking.swift" file and replace "Mastodon.example" with your instance in the mastodon instance variable
  5. Compile and Run "Stray Toots" for the companion iPhone app
  6. Compile and Run "Stray Toots Watch App" for the Watch App (which will have the Toots)

Personal Note

This README, and it's project, is a continual work in progress. Although there are good Swift Package Managers that can make some of these tasks much easier, I wanted to initially make sure I understand some basic networking concepts and can read and understand API documentation. I also want to start Toot-ing as much as I Tweet.

Update July 2023 - making this project Open Source in case others would like to learn from it or develop it into something else, as I don't have the personal bandwidth to properly support it for a while.

This Project is covered by the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages