Skip to content

Instantly share code, notes, and snippets.

@johnspurlock-skymethod
Last active March 13, 2022 21:46
Show Gist options
  • Save johnspurlock-skymethod/f1bd7daa7071db616bfc39f8b508baab to your computer and use it in GitHub Desktop.
Save johnspurlock-skymethod/f1bd7daa7071db616bfc39f8b508baab to your computer and use it in GitHub Desktop.
reply-flow-with-webfinger

For a given target post activity pub id url, say: https://example.com/@alice/posts/9b905f9a-f607-4d97-8b6a-e4f212b07561

  1. Prompt for the user's fediverse identity, say: @bob@bobsdomain.com
  2. Issue a webfinger request to find the redirect url:
GET https://bobsdomain.com/.well-known/webfinger?resource=acct:bob@bobsdomain.com

200 OK
content-type: application/jrd+json; charset=utf-8
{
  "subject": "acct:bob@bobsdomain.com",
  "aliases": [
    "https://bobsdomain.com/@bob",
    "https://bobsdomain.com/users/bob"
  ],
  "links": [
    {
      "rel": "http://webfinger.net/rel/profile-page",
      "type": "text/html",
      "href": "https://bobsdomain.com/@bob"
    },
    {
      "rel": "self",
      "type": "application/activity+json",
      "href": "https://bobsdomain.com/users/bob"
    },
    {
      "rel": "http://ostatus.org/schema/1.0/subscribe",
      "template": "https://bobsdomain.com/authorize_interaction?uri={uri}"
    }
  ]
}
  1. Use the url template from the object with "rel": "http://ostatus.org/schema/1.0/subscribe" and redirect the user to it, replacing {uri} with the url encoded version of the target post activity pub id url
GET https://bobsdomain.com/authorize_interaction?uri=https%3A%2F%2Fexample.com%2F%40alice%2Fposts%2F9b905f9a-f607-4d97-8b6a-e4f212b07561
  1. This will prompt the user to login, then display the target post on that server's UI. The user will be able to favorite, reply, follow, etc from there
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment