fetchCurrentOAuth2Information method

Future<OAuth2Information> fetchCurrentOAuth2Information()

Implementation

Future<OAuth2Information> fetchCurrentOAuth2Information() async {
  final route = HttpRoute()
    ..oauth2()
    ..add(HttpRoutePart('@me'));
  final request = BasicRequest(route);
  final response = await client.httpHandler.executeSafe(request);
  final body = response.jsonBody as Map<String, Object?>;
  return OAuth2Information(
      application: PartialApplication(manager: client.applications, id: Snowflake.parse((body['application'] as Map<String, Object?>)['id']!)),
      scopes: (body['scopes'] as List).cast(),
      expiresOn: DateTime.parse(body['expires'] as String),
      user: maybeParse(body['user'], client.users.parse));
}