Skip to content

Commit

Permalink
0.6.0 release (#151)
Browse files Browse the repository at this point in the history
- Reddit.restoreAuthenticatedInstance now returns `Reddit` instead of
`Future<Reddit>`
- Reddit.restoreAuthenticatedInstance no longer requires a client secret
- Updated example and tests.
  • Loading branch information
bkonyi committed Jul 8, 2019
1 parent ea217cc commit 1a583ab
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,17 @@
Change Log
=================================

## Version 0.6.0 (2019/07/08)

### Breaking changes:
* `Reddit.restoreAuthenticatedInstance` now returns `Reddit` instead of `Future<Reddit>`.

### Other changes:
* `Reddit.restoreAuthenticatedInstance` no longer throws an exception when not provided a
`clientSecret`. A `clientSecret` is still required for most client types except for
installed applications.
* Updated dependencies.

## Version 0.5.2+1 (2019/05/31)
* Updated documentation.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -118,7 +118,7 @@ main() async {
await writeCredentials(reddit.auth.credentials.toJson());
} else {
// Create a new Reddit instance using previously cached credentials.
reddit = await Reddit.restoreAuthenticatedInstance(
reddit = Reddit.restoreAuthenticatedInstance(
userAgent: userAgent,
configUri: configUri,
credentialsJson: credentialsJson);
Expand Down
14 changes: 3 additions & 11 deletions lib/src/reddit.dart
Expand Up @@ -318,19 +318,19 @@ class Reddit {
///
/// [siteName] is the name of the configuration to use from draw.ini. Defaults
/// to 'default'.
static Future<Reddit> restoreAuthenticatedInstance(String credentialsJson,
static Reddit restoreAuthenticatedInstance(String credentialsJson,
{String clientId,
String clientSecret,
String userAgent,
Uri redirectUri,
Uri tokenEndpoint,
Uri authEndpoint,
Uri configUri,
String siteName = 'default'}) async {
String siteName = 'default'}) {
if (credentialsJson == null) {
throw DRAWArgumentError('credentialsJson cannot be null.');
}
final reddit = Reddit._webFlowInstanceRestore(
return Reddit._webFlowInstanceRestore(
clientId,
clientSecret,
userAgent,
Expand All @@ -340,11 +340,6 @@ class Reddit {
authEndpoint,
configUri,
siteName);
final initialized = await reddit._initializedCompleter.future;
if (initialized) {
return reddit;
}
throw DRAWAuthenticationError('Unable to authenticate with Reddit');
}

Reddit._readOnlyInstance(
Expand Down Expand Up @@ -514,9 +509,6 @@ class Reddit {
if (_config.clientId == null) {
throw DRAWAuthenticationError('clientId cannot be null.');
}
if (_config.clientSecret == null) {
throw DRAWAuthenticationError('clientSecret cannot be null.');
}
if (_config.userAgent == null) {
throw DRAWAuthenticationError('userAgent cannot be null.');
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
@@ -1,5 +1,5 @@
name: draw
version: 0.5.2+1
version: 0.6.0
description: 'A fully-featured Reddit API wrapper for Dart, inspired by PRAW.'
homepage: 'https://github.com/draw-dev/DRAW'
authors:
Expand Down
2 changes: 1 addition & 1 deletion test/auth/web_auth.dart
Expand Up @@ -123,7 +123,7 @@ Future<void> main() async {
final creds = reddit.auth.credentials.toJson();

// Attempt to create a new instance with the saved credentials.
final redditRestored = await Reddit.restoreAuthenticatedInstance(creds,
final redditRestored = Reddit.restoreAuthenticatedInstance(creds,
clientId: kWebClientID,
clientSecret: kWebClientSecret,
userAgent: userAgent);
Expand Down

0 comments on commit 1a583ab

Please sign in to comment.