Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
indieauth client/server setup code
<?php
// Create a micropub client app — allows users to log in and authorize this app to make requests on their behalf to,
// e.g. a micropub endpoint, authenticates requests based on remember-me cookie.
// $dataToCookie and $dataFromCookie map between the array of information about the current user and the string value
// stored in the remember-me cookie
//
// Adds routes:
// /login
// /authorize
// /logout
//
// Adds ->before() handler which attaches data about the current user, which scopes they’ve granted this app (if any)
// their URL, access token and micropub endpoint to $request.
$app->mount('/', Authentication\client($app, $dataToCookie, $dataFromCookie));
// Create a micropub server app + token provider — creates token-providing and authorizing endpoints, allows users to
// authorize other apps to make requests to this one on their behalf, authenticates requests based on access tokens.
// $dataToToken and $dataFromToken map the access token granted to+used by apps and a user+client id+granted scopes
//
// Adds routes:
// /token
//
// Adds ->before() handler which attaches data about the current user, which app they’re using, what scopes they’re
// granted on this server to $request.
$app->mount('/', Authentication\server($app, $dataToToken, $dataFromToken));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.