atproto_oauth 0.5.1 copy "atproto_oauth: ^0.5.1" to clipboard
atproto_oauth: ^0.5.1 copied to clipboard

Provides tools to handle OAuth for AT Protocol and Bluesky Social.

example/example.dart

import 'package:atproto_oauth/atproto_oauth.dart';

Future<void> main() async {
  final metadata = await getClientMetadata(
    'https://atprotodart.com/oauth/bluesky/atprotodart/client-metadata.json',
  );

  final client = OAuthClient(metadata);

  // Resolves the identity, discovers its authorization server, performs the
  // pushed authorization request, and persists the per-authorization state
  // in the (in-memory by default) state store keyed by `state`.
  final url = await client.authorize('shinyakato.dev');

  print(url);

  //! Make user visit url.
  //! Then, once it was redirected to the callback URI, perform the following.
  //! The `state` in the callback URL is used to recover the stored context.

  final session = await client.callback(
    'https://atprotodart.com/oauth/bluesky/auth.html'
    '?iss=xxxx&state=xxxxxxx&code=xxxxxxx',
  );

  print(session.accessToken);
  print(session.refreshToken);
  print(session.pds);

  // Later, restore the session from the store (refreshing it if expired), or
  // refresh/revoke it explicitly.
  final restored = await client.restore(session.sub);
  print(restored?.accessToken);
}
1
likes
140
points
3.37k
downloads

Documentation

API reference

Publisher

verified publisheratprotodart.com

Weekly Downloads

Provides tools to handle OAuth for AT Protocol and Bluesky Social.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#atproto #bluesky #oauth

Funding

Consider supporting this project:

github.com

License

BSD-3-Clause (license)

Dependencies

atproto_identity, convert, crypto, freezed_annotation, http, json_annotation, pointycastle

More

Packages that depend on atproto_oauth