createReadOnlyInstance static method

Future<Reddit> createReadOnlyInstance({
  1. String? clientId,
  2. String? clientSecret,
  3. String? userAgent,
  4. Uri? tokenEndpoint,
  5. Uri? authEndpoint,
  6. Uri? configUri,
  7. String siteName = 'default',
})

Creates a new read-only Reddit instance for web and script applications.

clientId is the identifier associated with your authorized application on Reddit. To get a client ID, create an authorized application here.

clientSecret is the unique secret associated with your client ID. This is required for script and web applications.

userAgent is an arbitrary identifier used by the Reddit API to differentiate between client instances. This should be relatively unique.

tokenEndpoint is a Uri to an alternative token endpoint. If not provided, defaultTokenEndpoint is used.

authEndpoint is a Uri to an alternative authentication endpoint. If not provided, defaultAuthTokenEndpoint is used.

configUri is a Uri pointing to a 'draw.ini' file, which can be used to populate the previously described parameters.

siteName is the name of the configuration to use from draw.ini. Defaults to 'default'.

Implementation

static Future<Reddit> createReadOnlyInstance(
    {String? clientId,
    String? clientSecret,
    String? userAgent,
    Uri? tokenEndpoint,
    Uri? authEndpoint,
    Uri? configUri,
    String siteName = 'default'}) async {
  final reddit = Reddit._readOnlyInstance(clientId, clientSecret, userAgent,
      tokenEndpoint, authEndpoint, configUri, siteName);
  final initialized = await reddit._initializedCompleter.future;
  if (initialized) {
    return reddit;
  }
  throw DRAWAuthenticationError('Unable to authenticate with Reddit');
}