diff --git a/CHANGELOG.md b/CHANGELOG.md index 675e29bc..df13b214 100644 --- a/CHANGELOG.md +++ b/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`. + +### 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. diff --git a/README.md b/README.md index 8eb7b0ab..e16e7cc3 100644 --- a/README.md +++ b/README.md @@ -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); diff --git a/lib/src/reddit.dart b/lib/src/reddit.dart index 0f99f723..f9851d54 100644 --- a/lib/src/reddit.dart +++ b/lib/src/reddit.dart @@ -318,7 +318,7 @@ class Reddit { /// /// [siteName] is the name of the configuration to use from draw.ini. Defaults /// to 'default'. - static Future restoreAuthenticatedInstance(String credentialsJson, + static Reddit restoreAuthenticatedInstance(String credentialsJson, {String clientId, String clientSecret, String userAgent, @@ -326,11 +326,11 @@ class Reddit { 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, @@ -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( @@ -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.'); } diff --git a/pubspec.yaml b/pubspec.yaml index 24ab1236..20939ad4 100644 --- a/pubspec.yaml +++ b/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: diff --git a/test/auth/web_auth.dart b/test/auth/web_auth.dart index 6e490e8b..81e3c6ad 100644 --- a/test/auth/web_auth.dart +++ b/test/auth/web_auth.dart @@ -123,7 +123,7 @@ Future 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);