createUntrustedReadOnlyInstance static method
Creates a new read-only Reddit
instance for installed application types.
This method should be used to create a read-only instance in circumstances where a client secret would not be secure.
clientId
is the identifier associated with your authorized application
on Reddit. To get a client ID, create an authorized application
here.
deviceId
is a unique ID per-device or per-user. See
Application Only OAuth
for best practices regarding device IDs.
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> createUntrustedReadOnlyInstance(
{String? clientId,
String? deviceId,
String? userAgent,
Uri? tokenEndpoint,
Uri? authEndpoint,
Uri? configUri,
String siteName = 'default'}) async {
final reddit = Reddit._untrustedReadOnlyInstance(clientId, deviceId,
userAgent, tokenEndpoint, authEndpoint, configUri, siteName);
final initialized = await reddit._initializedCompleter.future;
if (initialized) {
return reddit;
}
throw DRAWAuthenticationError(
'Unable to get valid OAuth token for read-only instance');
}