Comments (16)
Crossposted from @irace's fork:
Talked about this with Jared Sinclair and he's keen to build the UI for (at least a basic version of) Tumblr sharing if I provide the networking and authentication bits in the form of a helper class. I admittedly haven't tried using OSK in an app myself yet, nor have gone through enough of the code to get an idea of how authentication is generally implemented across services.
The best way to auth with the Tumblr API is using OAuth (xAuth support exists but is whitelisted, generally frowned upon, and not given access to unless absolutely necessary). The Tumblr iOS SDK includes support for both of these so I'm happy to hook up whichever Jared prefers, but please note that the OAuth implementation currently in there requires bouncing out to Safari, which means any app that uses this would need to implement a custom URL protocol to return back to, and OSK would need to be all up in the app delegate's application:openURL:sourceApplication:annotation: business.
Another possibly better option would to OAuth via in in-app UIWebView; there's a pull request open to add this to TMTumblrSDK and I'm fine with taking a look at it and either merging or implementing it differently myself, I just haven't gotten around to it yet. OSK integration would be enough impetus to do so however.
The Tumblr SDK already has a TMTumblrSDK/Authentication sub spec which could be used to implement this new helper class, though I notice that OSK doesn't currently important any dependencies using CocoaPods – it instead does so via git submodules would would require importing all of TMTumblrSDK and it's dependencies, so let's opt against that and I'll just copy/paste the pertinent code over.
from overshare-kit.
OSK provides four paths for authentication:
OSKAuthenticationMethod_SystemAccounts
– Twitter, Facebook – Where possible, OvershareKit uses accounts managed via iOS' native account frameworks.OSKAuthenticationMethod_ManagedAccounts
– App.net, Instapaper, Etc. – Third party services that provide a means to have multiple authenticated accounts. Authentication methods include xAuth, oAuth, and Basic Auth, but are not limited to those. App.net, for example, can optionally authenticate via the App.net Passport application. Authentication for built-in OSK activities is a coordinated effort between several classes. More on this below.OSKAuthenticationMethod_Generic
– Pocket – Third party services that provide only an opaque means of authentication, limited to a boolean check for "isAuthenticated" or similar. Generic authentication therefore does not support multiple accounts.OSKAuthenticationMethod_None
– 1Password, Safari, Etc. – No authentication needed.
Authentication is a coordinated effort between several classes. A given subclass of OSKActivity is the most important component. OSKActivity subclasses must override a number of required methods that return parameters that OSK needs to properly advance the user through authentication and publishing steps. For example, an activity must provide which type of authentication it uses (if any) via the authenticationMethod
class method. OSK queries other methods of a given activity to determine whether to show authentication view controllers, and which view controllers to show.
The end result of an authentication for activities that use OSKAuthenticationMethod_ManagedAccounts
is an instance of OSKManagedAccount
. This class is not meant to be subclassed. Existing accounts are accessed through OSKManagedAccountStore
, which is also responsible for serializing accounts to disk as needed. OSKManagedAccount
stores its credentials (passwords, tokens, etc.) in the Keychain. Items without security requirements are written to disk via NSCoding.
When integrating a new service with OSK, the only "new" code that needs to be added, other than an OSKActivity subclass, is code for any utilities or view controllers needed to produce a new instance of OSKManagedAccount. Most of the time, this can be accomplished by the activity subclass itself, perhaps with the help of a utility class. Subclassable view controllers for web-based sign in, and for username/password flows, are already available in OSK.
For Tumblr, I think OSKAuthenticationMethod_ManagedAccounts
makes the most sense, especially when combined with the web-based flow. OSK already has a subclassable authentication web view controller which is used by OSKAppDotActivity
. Other authentication methods would work as well.
I am happy to wire up Tumblr into OSK's authentication and publishing steps, providing view controllers wherever needed. The part that I'd like you to help with is providing utility classes to serve as an interface between the Tumblr API and OSK. For an example of what I mean, check out OSKAppDotNetUtility
.
from overshare-kit.
A rough spec for a bare-bones Tumblr utility would include simple methods for creating new posts, e.g.:
- (void)sendPost:title:text:blah:blah:completion:
If we use a web-based flow, Tumblr would also need a subclass of OSKWebViewController
. This subclass must also conform to the OSKAuthenticationViewController
protocol. This view controller, and any utility classes it might need, should be able to load the web-based starting point for authentication, and finish with the creation of a new OSKManagedAccount.
from overshare-kit.
So, your rough method spec there has individual fields for things like "title", "text", etc., where the ADN utility you pointed me at instead takes an object of type OSKBlogPostContentItem
. Which is the right way to go?
from overshare-kit.
I can see arguments for both. If we use OSKBlogPostContentItem
, it will be easy to add/remove properties on the content item without having to rewrite the signatures for the utility methods every time—the blog post item would be the only argument, and it is unlikely that this argument would need to change. On the other hand, explicitly listing the required data as individual method args (title, text, etc.) makes the requirements harder to miss.
I say we use OSKBlogPostContentItem
.
from overshare-kit.
Also, we should schedule a time to chat on ADN PMs or something.
from overshare-kit.
What's the progress on this?
Wouldn't be just easier to drop submodules and add dependencies via Cocoapods, so TMTumblrSDK on the Tumblr Utility?
I've been using TMTumblrSDK and it's quite simple and convenient.
from overshare-kit.
Wouldn't be just easier to drop submodules and add dependencies via Cocoapods, so TMTumblrSDK on the Tumblr Utility?
Most of the complexity is in the UI, considering a user can have multiple blogs, can make posts of seven different types, etc. Based on @jaredsinclair's comments about the future of OvershareKit in the impending iOS 8 extension landscape, it might not be worth it. We plan to expose a share extension from Tumblr.app.
Glad you're finding TMTumblrSDK enjoyable to use though!
from overshare-kit.
Thanks for the update, that's a good point about iOS 8.
However I think iOS 7 support is relevant at least until iOS 9 is released. I think we'll try to fork OSK and hack a very simple barebones Tumblr activity (we only need the text post type for our app).
from overshare-kit.
I think we'll try to fork OSK and hack a very simple barebones Tumblr activity (we only need the text post type for our app).
Sounds like a good course of action to me at least.
from overshare-kit.
@irace I've been working on this but I've hit a wall.
I'm using felixmo's changes to TMTumblrSDK for UIWebView authentication (merged with the latest official TMTumblrSDK head). However, when I try to authenticate via the UIWebView, I get an error:
Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)" UserInfo=0x178267340 {NSErrorFailingURLStringKey=http://www.tumblr.com/oauth/request_token?oauth_callback=overshare%3A%2F%2Ftumblr-authorize, NSUnderlyingError=0x1780514c0 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1012.)", NSErrorFailingURLKey=http://www.tumblr.com/oauth/request_token?oauth_callback=overshare%3A%2F%2Ftumblr-authorize}
I think I am setting [TMTumblrAuthenticator sharedInstance].OAuthConsumerKey
and [TMTumblrAuthenticator sharedInstance].OAuthConsumerSecret
correctly so that should not be the issue.
Could you give me hand?
See my forks here (I ended up adding TMTumblrSDK plus JXHTTP as OvershareKit submodules):
from overshare-kit.
It turns out something was wrong with the app key and secret. I'm using a different one and I'm making progress again. So no worries.
Sorry about that!
UPDATE: It turns out the error was due to not clearing the tumblr cookies from a failed authorization attempt.
from overshare-kit.
I finished the UITumblrActivity implementation. You can check it out on my fork.
I submitted a pull request just in case you want to add it.
from overshare-kit.
UPDATE: It turns out the error was due to not clearing the tumblr cookies from a failed authorization attempt.
Hi. I'm seeing same issue here. Trying to follow your idea of clearing cookies for tumblr.com
and www.tumblr.com
before starting oAuth but that doesn't seem to help. Can you please give some details on how you solved that problem?
from overshare-kit.
Clearing the cookies worked for me. Try to clear them from a OSKWebViewController
subclass like this:
[self clearCookiesForBaseURLs:@[@"https://tumblr.com", @"https://www.tumblr.com"]];
from overshare-kit.
@rsanchezsaez that was the first I tried. Didn't work.
Turned out it's a iOS HTTP framework weirdness. OAuth assumes that initial request for oauth_token and secret is OAuth signed and signature includes initial URL (http://www.tumblr.com/oauth/request_token...). Here's that request from TMTumblrAuthenticator
NSString *tokenRequestURLString = [NSString stringWithFormat:@"http://www.tumblr.com/oauth/request_token?oauth_callback=%@/",
TMURLEncode([NSString stringWithFormat:@"%@://tumblr-authorize", URLScheme])];
For some reason, iOS modifies this NSURLRequest
somewhere internally and turns it into https://...
Since url changed, Tumblr's backend fails to match oauth_signature.
Changing initial request to https:// solves my problem. gonna make pull request into TMTumblrAuthenticator
.
from overshare-kit.
Related Issues (20)
- Update Instapaper icons for new version
- Network or authentication errors should be passed all the way up.
- Sorting activity
- Facebook audience button not localized.
- How can I add a custom activity?
- Implemented Sina Weibo and Tencent Weibo activities HOT 1
- Many instances of 'release' and 'retain' (pre-ARC) and other errors HOT 1
- MPMoviePlayerThumbnailImageKey GooglePlus error HOT 4
- Documentation regarding installation
- Email default appearance HOT 1
- Email Share Generates Service Termination Error on iOS 8 HOT 1
- Undefined symbols for architecture x86_64 - GooglePlus HOT 1
- Unable to submit apps due to GooglePlus framework causing validation errors HOT 3
- i think the "time" must be the "_authenticationTimeoutTimer"
- Existing FacebookSDK Integration
- How to setup my Facebook APP key?
- Is it possible to add Wechat and Weibo SDK?
- Sharing of Facebook Open Graph stories?
- Unable to simply use Facebook for sharing without a developer account set up?
- Facebook strings not all translated
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from overshare-kit.