From e31f9e08aa341e8f31496d5dd7ff6b5cce23c1e8 Mon Sep 17 00:00:00 2001 From: Drew McCormack Date: Mon, 28 Mar 2022 15:37:46 +0200 Subject: [PATCH] Updated Dropbox to 6.2.3. Added new authenticate method and scopes for Dropbox in Idiomatic. --- Examples/Idiomatic/Idiomatic/IDMSyncManager.m | 66 ++++++++++--------- RELEASENOTES.md | 6 +- Vendor/DropboxSDKV2 | 2 +- 3 files changed, 40 insertions(+), 34 deletions(-) diff --git a/Examples/Idiomatic/Idiomatic/IDMSyncManager.m b/Examples/Idiomatic/Idiomatic/IDMSyncManager.m index 91e53d78..1965bd3b 100644 --- a/Examples/Idiomatic/Idiomatic/IDMSyncManager.m +++ b/Examples/Idiomatic/Idiomatic/IDMSyncManager.m @@ -262,36 +262,33 @@ - (void)persistentStoreEnsemble:(CDEPersistentStoreEnsemble *)ensemble didDeleec - (BOOL)handleOpenURL:(NSURL *)url { - DBOAuthResult *authResult = [DBClientsManager handleRedirectURL:url]; - if (!authResult) { - return NO; - } - - if ([authResult isSuccess]) { - // Here's an example of injecting a custom API client created from an access token - // (e.g. when working in a multi-user environment) - if ([cloudFileSystem isKindOfClass:[CDEDropboxV2CloudFileSystem class]]) { - CDEDropboxV2CloudFileSystem *dropboxSystem = cloudFileSystem; - if (!dropboxSystem.client) { - NSString *accessToken = authResult.accessToken.accessToken; - dropboxSystem.client = [[DBUserClient alloc] initWithAccessToken:accessToken]; + [DBClientsManager handleRedirectURL:url completion: ^(DBOAuthResult *authResult) { + if ([authResult isSuccess]) { + // Here's an example of injecting a custom API client created from an access token + // (e.g. when working in a multi-user environment) + if ([self->cloudFileSystem isKindOfClass:[CDEDropboxV2CloudFileSystem class]]) { + CDEDropboxV2CloudFileSystem *dropboxSystem = self->cloudFileSystem; + if (!dropboxSystem.client) { + NSString *accessToken = authResult.accessToken.accessToken; + dropboxSystem.client = [[DBUserClient alloc] initWithAccessToken:accessToken]; + } } + dispatch_async(dispatch_get_main_queue(), ^{ + if (self->dropboxLinkSessionCompletion) self->dropboxLinkSessionCompletion(nil); + self->dropboxLinkSessionCompletion = NULL; + }); } - dispatch_async(dispatch_get_main_queue(), ^{ - if (self->dropboxLinkSessionCompletion) self->dropboxLinkSessionCompletion(nil); - self->dropboxLinkSessionCompletion = NULL; - }); - } - else { - NSError *error = [NSError errorWithDomain:CDEErrorDomain - code:CDEErrorCodeAuthenticationFailure - userInfo:nil]; - dispatch_async(dispatch_get_main_queue(), ^{ - if (self->dropboxLinkSessionCompletion) self->dropboxLinkSessionCompletion(error); - self->dropboxLinkSessionCompletion = NULL; - }); - } - + else { + NSError *error = [NSError errorWithDomain:CDEErrorDomain + code:CDEErrorCodeAuthenticationFailure + userInfo:nil]; + dispatch_async(dispatch_get_main_queue(), ^{ + if (self->dropboxLinkSessionCompletion) self->dropboxLinkSessionCompletion(error); + self->dropboxLinkSessionCompletion = NULL; + }); + } + }]; + return YES; } @@ -304,13 +301,18 @@ - (void)linkSessionForDropboxCloudFileSystem:(CDEDropboxV2CloudFileSystem *)file }); return; } - + dropboxLinkSessionCompletion = [completion copy]; + + // We need these Dropbox scopes: account_info.read, files.metadata.write, files.metadata.read, files.content.write, files.content.read + // Enable these scopes in your Dropbox App Console at developer.dropbox.com UIApplication *application = [UIApplication sharedApplication]; UIViewController *rootController = [[application keyWindow] rootViewController]; - [DBClientsManager authorizeFromController:application - controller:rootController - openURL:^(NSURL *url){ [[UIApplication sharedApplication] openURL:url]; }]; + [DBClientsManager authorizeFromControllerV2:application + controller:rootController + loadingStatusDelegate:nil + openURL:^(NSURL *url){ [[UIApplication sharedApplication] openURL:url]; } + scopeRequest:nil]; } - (void)applicationDidBecomeActive:(NSNotification *)notif diff --git a/RELEASENOTES.md b/RELEASENOTES.md index ab29a2e0..1ff05ea2 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,7 +1,11 @@ Release Notes ============= -NEXT +1.10 +--- +- Updated Dropbox to 6.2.3, and introduced Dropbox scopes for Idiomatic. + +1.9 --- - Introduced custom value transformer for CDEPropertyValueChange to silence secure transformer warnings - Added code to handle secure attribute transformers in user model diff --git a/Vendor/DropboxSDKV2 b/Vendor/DropboxSDKV2 index 1d12a3bb..2c9997be 160000 --- a/Vendor/DropboxSDKV2 +++ b/Vendor/DropboxSDKV2 @@ -1 +1 @@ -Subproject commit 1d12a3bbd7adbc1265ad9571c977012cd4b9236b +Subproject commit 2c9997be7370b783a7041e12dd49e0862fda83dd