Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Update AFOAuth1Client to use ARC and latest AFNetworking #10

Closed
wants to merge 6 commits into from

Conversation

rdougan
Copy link

@rdougan rdougan commented Dec 17, 2012

I've updated AFOAuth1Client to use ARC and use the latest version of AFNetworking (via a submodule).

Both the iOS and OSX example apps have also been updated.

There are two issues:

  1. I had to copy AFPercentEscapedQueryStringPairMemberFromStringWithEncoding from AFHTTPClient.m into AFOAuth1Client.m as you cannot access it any other way.
  2. The UIApplicationDidFinishLaunchingNotification notification does not get called when relaunching the app from the background (which always happens when we authenticate with OAuth). I'm not sure how else we can get the URL.

Let me know your thoughts.

@iamcam
Copy link

iamcam commented Dec 21, 2012

I'm seeing an error with the nonce creation - it's just returning the same string. It doesn't seem to be a problem with the Twitter client, but Tumblr immediately complains if the nonce is re-used.

@iamcam
Copy link

iamcam commented Dec 21, 2012

I toyed around with this for a little while and found where @mattt explained to another that he doesn't want to expose AFBase64EncodedStringFromString externally, so I created an NSString category copy of that method (different name): https://gist.github.com/4351190

So, in static inline NSString * AFNonceWithPath(NSString *path) you can swap it the return with

[NSString encodeBase64FromString:[[NSString stringWithFormat:@"%@-%@", path, [[NSDate date] description]] substringWithRange:NSMakeRange(0, 10)]]

@iamcam
Copy link

iamcam commented Dec 21, 2012

I also want to add that this implementation is incomplete -

- (void)acquireOAuthAccessTokenWithPath:(NSString *)path
                           requestToken:(AFOAuth1Token *)requestToken
                                success:(void (^)(AFOAuth1Token *accessToken))success 
                                failure:(void (^)(NSError *error))failure

needs to be completed (currently commented out). I tried it with the Tumblr api, and I can't get the auth to complete, though I don't know if it's due to an error in this method or somewhere else; more investigation is needed.

I'm probably done working on this problem for now, but I'll check back in when more progress is made.

@choco
Copy link
Contributor

choco commented Dec 24, 2012

Please take a look at the mattt-joergsimon-merge branch. That is the most updated version and you should contribute to it.

Most of the issues you reported are already solved there, what it's still needed is:

  • porting AFOAuth1Client to ARC (really simple, since we are only subclassing AFHTTPClient)
  • copying AFPercentEscapedQueryStringPairMemberFromStringWithEncoding over to AFOAuth1Client since AFURLEncodedStringFromStringWithEncoding got removed it the last versions of AFNetworking
  • Fixing a stupid bug in
- (void)acquireOAuthAccessTokenWithPath:(NSString *)path
                           requestToken:(AFOAuth1Token *)requestToken
                           accessMethod:(NSString *)accessMethod
                                success:(void (^)(AFOAuth1Token *accessToken))success 
                                failure:(void (^)(NSError *error))failure;

that prevents us from calculating the correct signature, for example with Tumblr (with Twitter it works because they're really permissive...)

  • refractoring the code
  • updating all example projects to ARC
  • fixing other bugs (?)
  • fixing some bad design choices (?)

I had some free time today and fixed all these points apart from the last one since I need to open an issue and discuss with @mattt what I don't like about the current design.
I'll submit the pull request tomorrow, because I have to run some tests to check the code.
It should be a nice Christmas present :)

@iamcam
Copy link

iamcam commented Dec 29, 2012

Awesome, thanks for looking into it. Please post a link to the pull request when you have a chance. I don't know if I'll have an opportunity soon to take a look at the last issue, but I'll let you know if I do so we aren't duplicating any work.

@mattt
Copy link
Contributor

mattt commented Jan 21, 2013

Good news! Thanks to all of your contributions, the project overhaul is now complete (as of 57e8897).

A stable release (0.1.0) was just added to CocoaPods.

I know a lot of y'all had been waiting a long time in the dark for this, and I'm truly sorry about that. I'm happy to be able to say that this project is finally up to the standards of AFNetworking.

@mattt mattt closed this Jan 21, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants