Skip to content

Commit

Permalink
Remove browser auth.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Cobbe committed Apr 11, 2017
1 parent 33dc18a commit 8936d7f
Show file tree
Hide file tree
Showing 31 changed files with 428 additions and 771 deletions.
4 changes: 2 additions & 2 deletions ObjectiveDropboxOfficial.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ Pod::Spec.new do |s|
s.osx.public_header_files = 'Source/ObjectiveDropboxOfficial/Platform/ObjectiveDropboxOfficial_macOS/**/*.h'
s.ios.public_header_files = 'Source/ObjectiveDropboxOfficial/Platform/ObjectiveDropboxOfficial_iOS/**/*.h'

s.osx.frameworks = 'AppKit', 'WebKit', 'SystemConfiguration', 'Foundation'
s.ios.frameworks = 'UIKit', 'WebKit', 'SystemConfiguration', 'Foundation'
s.osx.frameworks = 'AppKit', 'SafariServices', 'SystemConfiguration', 'Foundation'
s.ios.frameworks = 'UIKit', 'SafariServices', 'SystemConfiguration', 'Foundation'
end
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Then navigate to the directory that contains your project and create a new file
##### iOS

```ruby
platform :ios, '8.0'
platform :ios, '9.0'
use_frameworks!

target '<YOUR_PROJECT_NAME>' do
Expand Down Expand Up @@ -277,11 +277,10 @@ After you've made the above changes, your application's `.plist` file should loo

### Handling the authorization flow

There are three methods to programmatically retrieve an OAuth 2.0 access token:
There are two methods to programmatically retrieve an OAuth 2.0 access token:

* **Direct auth** (iOS only): This launches the official Dropbox iOS app (if installed), authenticates via the official app, then redirects back into the SDK
* **In-app webview auth** (iOS, macOS): This opens a pre-built in-app webview for authenticating via the Dropbox authorization page. This is convenient because the user is never redirected outside of your app.
* **External browser auth** (iOS, macOS): This launches the platform's default browser for authenticating via the Dropbox authorization page. This is desirable because it is safer for the end-user, and pre-existing session data can be used to avoid requiring the user to re-enter their Dropbox credentials.
* **External browser auth** (iOS, macOS): This launches the platform's default browser for authenticating via the Dropbox authorization page. For iOS >= 9, a `SFSafariViewController` is used instead of an external browser. This is desirable because it is safer for the end-user, and pre-existing session data can be used to avoid requiring the user to re-enter their Dropbox credentials.

To facilitate the above authorization flows, you should take the following steps:

Expand Down Expand Up @@ -315,8 +314,8 @@ To facilitate the above authorization flows, you should take the following steps

#### Begin the authorization flow

You can commence the auth flow by calling `authorizeFromController:controller:openURL:browserAuth` method in your application's
view controller. If you wish to authenticate via the in-app webview, then set `browserAuth` to `NO`. Otherwise, authentication will be done via an external web browser.
You can commence the auth flow by calling `authorizeFromController:controller:openURL` method in your application's
view controller.

##### iOS

Expand All @@ -328,8 +327,7 @@ view controller. If you wish to authenticate via the in-app webview, then set `b
controller:self
openURL:^(NSURL *url) {
[[UIApplication sharedApplication] openURL:url];
}
browserAuth:YES];
}];
}

```
Expand All @@ -342,8 +340,7 @@ view controller. If you wish to authenticate via the in-app webview, then set `b
- (void)myButtonInControllerPressed {
[DBClientsManager authorizeFromControllerDesktop:[NSWorkspace sharedWorkspace]
controller:self
openURL:^(NSURL *url){ [[NSWorkspace sharedWorkspace] openURL:url]; }
browserAuth:YES];
openURL:^(NSURL *url){ [[NSWorkspace sharedWorkspace] openURL:url]; }];
}
```

Expand Down Expand Up @@ -600,7 +597,7 @@ DBFILESCommitInfo *commitInfo = [[DBFILESCommitInfo alloc] initWithPath:@"/outpu
if ([resultEntry isSuccess]) {
NSString *dropboxFilePath = resultEntry.success.pathDisplay;
NSLog(@"File successfully uploaded from %@ on local machine to %@ in Dropbox.",
[clientSideFileUrl absoluteString], dropboxFilePath);
[clientSideFileUrl path], dropboxFilePath);
} else if ([resultEntry isFailure]) {
// This particular file was not uploaded successfully, although the other
// files may have been uploaded successfully. Perhaps implement some retry
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
///
/// Copyright (c) 2016 Dropbox, Inc. All rights reserved.
///

#import <Foundation/Foundation.h>

#import "DBOAuthManager.h"

@interface DBOAuthManager (Protected)

- (DBOAuthResult * _Nonnull)extractFromRedirectURL:(NSURL * _Nonnull)url;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
///
/// Copyright (c) 2016 Dropbox, Inc. All rights reserved.
/// Copyright (c) 2011 BJ Homer. All rights reserved.
///

/*
* System Versioning Preprocessor Macros
*/

#define SYSTEM_VERSION_EQUAL_TO(v) \
([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) \
([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) \
([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) \
([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) \
([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

#import <Foundation/Foundation.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import <WebKit/WebKit.h>

#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#import <SafariServices/SafariServices.h>
#elif TARGET_OS_MAC
#import <AppKit/AppKit.h>
#import <Cocoa/Cocoa.h>
Expand Down
Loading

0 comments on commit 8936d7f

Please sign in to comment.