use v5.44.0;
use strict;
use warnings;
use Mojolicious::Lite -signatures;
use Mojo::ATProto::OAuth;
my $oauth = Mojo::ATProto::OAuth->new_localhost(
callback_url => "http://127.0.0.1:3000/callback",
scopes => ["atproto", "transition:generic"],
store => ["SQLite" => "file:/tmp/test.db?wal_mode=1"]
);
get "/" => sub ($c) {
$c->render(text => "welcome to the atwall!
log in at /login");
};
get "/login" => sub ($c) {
my $handle_or_did = "katproto.girlonthemoon.xyz";
my $redirect_url = $oauth->start_auth_flow(identifier => $handle_or_did);
$c->redirect_to($redirect_url);
};
get "/callback" => sub ($c) {
my $params = $c->req->params->to_hash;
my $session = $oauth->process_callback($params);
$c->render(text => "you are logged in as $session->{handle} ($session->{account_did})\n");
};
app->start;