Skip to content

Instantly share code, notes, and snippets.

Last active Aug 22, 2021
What would you like to do?
Installation, on 9front:
git/clone plan9front-oauth
cd plan9front-oauth
git/branch oauth
bind sys/include /sys/include
@{cd sys/src/libauth && mk install}
@{cd sys/src/cmd/auth && mk install}
@{cd sys/src/cmd/webfs && mk install}
This will replace your factotum.
You need to obtain OAuth credentials from your issuer first. See, for
example, Google's guide:
% echo 'key proto=oauth issuer= scope=email
client_id=1234 !client_secret=5678' > /mnt/factotum/ctl
% auth/oauth 'client_id=1234'
go to
your code is ABCD-EFGH
<after user consent is provided, the access token is printed>
auth_oauth is also available in libauth. Webfs uses it to implement
the preoauth command.
This code is specific to 9front, as libjson is required and Plan 9's
webfs doesn't support preoauth.
factotum uses the needkey RPC to display the verification URL and code
to the user. This means that, for now, the needkey file must not be
open so that fgui doesn't intercept it.
The module imports lots of code to support HTTP/1.0 so that the
refresh token doesn't leave factotum's address space.
The device, refresh and authorization code flows are supported.
However, the authorization code flow is not enabled by default as
it requires a plan9port plumber to be imported in factotum's namespace
(add flow=auth to your key to enable it). There is an implementation
of the authorization code flow for plan9port (tested on macOS) here: Start src/cmd/oauth/
on your p9p machine before running either implementation of the
authorization code flow.
Refresh tokens are not saved to persistent storage when factotum
exits. The user must provide consent every time factotum is restarted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment