Skip to content

Commit c4fb542

Browse files
committed
Merge pull request #73 from tumblr/remove-three-legged-oauth
Remove three legged OAuth
2 parents 388acc3 + e26f9c1 commit c4fb542

File tree

8 files changed

+1455
-603
lines changed

8 files changed

+1455
-603
lines changed

Podfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
platform :ios, '5.0'
1+
source 'https://github.com/CocoaPods/Specs.git'
22

3-
pod 'TMTumblrSDK', :local => 'TMTumblrSDK.podspec'
3+
platform :ios, '5.0'
44

5-
# Can't use podspec directive due to a bug: https://github.com/CocoaPods/CocoaPods/issues/928
6-
# podspec :name => 'TMTumblrSDK.podspec'
5+
podspec :name => 'TMTumblrSDK.podspec'
76

87
target :test, :exclusive => true do
98
link_with 'TMTumblrSDKTests'

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,18 @@ SDK does *not* currently persist these values; you are responsible for storing t
112112
the API client on subsequent app launches, before making any API requests. This may change in a future
113113
release.
114114

115-
### OAuth
115+
### OAuth (OS X only)
116+
117+
Unfortunately, [Apple has started rejecting apps](https://github.com/tumblr/TMTumblrSDK/issues/67#issuecomment-59384303)
118+
that use three-legged OAuth via Safari, the preferred way to retrieve access tokens from a security perspective. For
119+
the time being, please either:
120+
121+
* [Request xAuth access](http://www.tumblr.com/oauth/apps)
122+
* Use a web view inside of your application (here's [a TMTumblrSDK fork](https://github.com/felixmo/TMTumblrSDK/)
123+
that adds this capability, we may add it to the SDK proper at a later date)
124+
125+
We hope to have more to share on this note shortly.
126+
116127
In your app’s `Info.plist`, specify a custom URL scheme that the browser can
117128
use to return to your application once the user has permitted or denied
118129
access to Tumblr:
@@ -130,16 +141,7 @@ access to Tumblr:
130141
```
131142

132143
In your app delegate, allow the `TMAPIClient` singleton to handle incoming URL
133-
requests. On iOS this looks like:
134-
135-
``` objectivec
136-
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication
137-
annotation:(id)annotation {
138-
return [[TMAPIClient sharedInstance] handleOpenURL:url];
139-
}
140-
```
141-
142-
And on OS X:
144+
requests.
143145

144146
``` objectivec
145147
- (void)applicationWillFinishLaunching:(NSNotification *)notification {

TMTumblrSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'TMTumblrSDK'
3-
s.version = '1.1.1'
3+
s.version = '2.0'
44
s.summary = 'An unopinionated and flexible library for easily integrating Tumblr data into your iOS or OS X application.'
55
s.author = { 'Bryan Irace' => '[email protected]' }
66
s.homepage = 'http://tumblr.github.com/TMTumblrSDK'

TMTumblrSDK.xcodeproj/project.pbxproj

Lines changed: 1412 additions & 573 deletions
Large diffs are not rendered by default.

TMTumblrSDK/APIClient/TMAPIClient.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,17 @@ typedef void (^TMAPICallback)(id, NSError *error);
9292
*/
9393
- (void)sendRequest:(JXHTTPOperation *)request queue:(NSOperationQueue *)queue callback:(TMAPICallback)callback;
9494

95+
#ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
96+
9597
/** @name Authentication */
9698

9799
/**
98-
Authenticate via three-legged OAuth.
100+
Authenticate via three-legged OAuth.
99101
100-
Your `TMAPIClient` instance's `handleOpenURL:` method must also be called from your `UIApplicationDelegate`'s
102+
Your `TMAPIClient` instance's `handleOpenURL:` method must also be called from your `UIApplicationDelegate`'s
101103
`application:openURL:sourceApplication:annotation:` method in order to receive the tokens.
102104
103-
This method proxies to an underlying `TMTumblrAuthenticator`. That class can be used on its own but you do not need to
105+
This method proxies to an underlying `TMTumblrAuthenticator`. That class can be used on its own but you do not need to
104106
invoke it directly if you are including the whole API client in your project.
105107
106108
@param URLScheme a URL scheme that your application can handle requests to.
@@ -109,7 +111,7 @@ typedef void (^TMAPICallback)(id, NSError *error);
109111

110112
/**
111113
Authenticate via three-legged OAuth. This should be called from your `UIApplicationDelegate`'s
112-
`application:openURL:sourceApplication:annotation:` method in order to receive the tokens.
114+
`application:openURL:sourceApplication:annotation:` method in order to receive the tokens.
113115
114116
This method proxies to an underlying `TMTumblrAuthenticator`. That class can be used on its own but you do not need to
115117
invoke it directly if you are including the whole API client in your project.
@@ -118,6 +120,8 @@ typedef void (^TMAPICallback)(id, NSError *error);
118120
*/
119121
- (BOOL)handleOpenURL:(NSURL *)url;
120122

123+
#endif
124+
121125
/**
122126
Authenticate via xAuth. Please note that xAuth access [must be specifically requested](http://www.tumblr.com/oauth/apps)
123127
for your application.

TMTumblrSDK/APIClient/TMAPIClient.m

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,24 @@ + (instancetype)sharedInstance {
3535

3636
#pragma mark - Authentication
3737

38+
#ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
39+
3840
- (void)authenticate:(NSString *)URLScheme callback:(void(^)(NSError *))callback {
3941
[[TMTumblrAuthenticator sharedInstance] authenticate:URLScheme
4042
callback:^(NSString *token, NSString *secret, NSError *error) {
41-
self.OAuthToken = token;
42-
self.OAuthTokenSecret = secret;
43-
44-
callback(error);
45-
}];
43+
self.OAuthToken = token;
44+
self.OAuthTokenSecret = secret;
45+
46+
callback(error);
47+
}];
4648
}
4749

4850
- (BOOL)handleOpenURL:(NSURL *)url {
4951
return [[TMTumblrAuthenticator sharedInstance] handleOpenURL:url];
5052
}
5153

54+
#endif
55+
5256
- (void)xAuth:(NSString *)emailAddress password:(NSString *)password callback:(void(^)(NSError *))callback {
5357
return [[TMTumblrAuthenticator sharedInstance] xAuth:emailAddress password:password
5458
callback:^(NSString *token, NSString *secret, NSError *error) {

TMTumblrSDK/Authentication/TMTumblrAuthenticator.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ typedef void (^TMAuthenticationCallback)(NSString *, NSString *, NSError *);
2121

2222
+ (TMTumblrAuthenticator *)sharedInstance;
2323

24+
#ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
25+
2426
/**
2527
Authenticate via three-legged OAuth.
2628
@@ -39,6 +41,8 @@ typedef void (^TMAuthenticationCallback)(NSString *, NSString *, NSError *);
3941
*/
4042
- (BOOL)handleOpenURL:(NSURL *)url;
4143

44+
#endif
45+
4246
/**
4347
Authenticate via xAuth.
4448

TMTumblrSDK/Authentication/TMTumblrAuthenticator.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ + (id)sharedInstance {
4141
return instance;
4242
}
4343

44+
#ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
45+
4446
- (void)authenticate:(NSString *)URLScheme callback:(TMAuthenticationCallback)callback {
4547
// Clear token secret in case authentication was previously started but not finished
4648
self.threeLeggedOAuthTokenSecret = nil;
@@ -73,12 +75,8 @@ - (void)authenticate:(NSString *)URLScheme callback:(TMAuthenticationCallback)ca
7375
[NSString stringWithFormat:@"https://www.tumblr.com/oauth/authorize?oauth_token=%@",
7476
responseParameters[@"oauth_token"]]];
7577

76-
#if __IPHONE_OS_VERSION_MIN_REQUIRED
77-
[[UIApplication sharedApplication] openURL:authURL];
78-
#else
7978
[[NSWorkspace sharedWorkspace] openURL:authURL];
80-
#endif
81-
79+
8280
} else {
8381
if (callback) {
8482
callback(nil, nil, errorWithStatusCode(statusCode));
@@ -150,6 +148,8 @@ - (BOOL)handleOpenURL:(NSURL *)url {
150148
return YES;
151149
}
152150

151+
#endif
152+
153153
- (void)xAuth:(NSString *)emailAddress password:(NSString *)password callback:(TMAuthenticationCallback)callback {
154154
NSDictionary *requestParameters = @{
155155
@"x_auth_username" : emailAddress,

0 commit comments

Comments
 (0)