Skip to content

Commit

Permalink
Updated Dropbox to 6.2.3.
Browse files Browse the repository at this point in the history
Added new authenticate method and scopes for Dropbox in Idiomatic.
  • Loading branch information
drewmccormack committed Mar 28, 2022
1 parent db261ba commit e31f9e0
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 34 deletions.
66 changes: 34 additions & 32 deletions Examples/Idiomatic/Idiomatic/IDMSyncManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Vendor/DropboxSDKV2
Submodule DropboxSDKV2 updated 921 files

0 comments on commit e31f9e0

Please sign in to comment.