appCredentials method

Future<AuthenticatedApplication> appCredentials({
  1. Uri? website,
  2. Uri? redirectUris,
  3. String clientName = "mastodon-dart",
  4. List<String> scopes = const ["write", "read", "push"],
})
inherited

Create a new application to obtain OAuth2 credentials.

POST /api/v1/apps

Implementation

Future<AuthenticatedApplication> appCredentials({
  Uri? website,
  Uri? redirectUris,
  String clientName = "mastodon-dart",
  List<String> scopes = const ["write", "read", "push"],
}) async {
  final response = await request(
    Method.post,
    "/api/v1/apps",
    payload: {
      "client_name": clientName,
      "redirect_uris": redirectUris == null
          ? "urn:ietf:wg:oauth:2.0:oob"
          : redirectUris.toString(),
      "scopes": scopes.join(" "),
      "website": website == null ? '' : website.toString(),
    },
  );

  return AuthenticatedApplication.fromJson(json.decode(response.body));
}