Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Introducing API-breaking changes to AFOAuth1Client

Adding scope parameter to AFOAuth1Client methods

Adding responseObject argument in success block parameter
  • Loading branch information...
commit 7eff30fcb5d2513c19425de2eb84e91e8628d5d0 1 parent 8e945e5
@mattt mattt authored
View
28 AFOAuth1Client/AFOAuth1Client.h
@@ -72,16 +72,6 @@ typedef enum {
/// @name Authenticating
///---------------------
-
-- (void)authorizeUsingOAuthWithRequestTokenPath:(NSString *)requestTokenPath
- userAuthorizationPath:(NSString *)userAuthorizationPath
- callbackURL:(NSURL *)callbackURL
- accessTokenPath:(NSString *)accessTokenPath
- accessMethod:(NSString *)accessMethod
- scope:(NSString *)scope
- success:(void (^)(AFOAuth1Token *accessToken))success
- failure:(void (^)(NSError *error))failure;
-
/**
*/
@@ -90,24 +80,18 @@ typedef enum {
callbackURL:(NSURL *)callbackURL
accessTokenPath:(NSString *)accessTokenPath
accessMethod:(NSString *)accessMethod
- success:(void (^)(AFOAuth1Token *accessToken))success
+ scope:(NSString *)scope
+ success:(void (^)(AFOAuth1Token *accessToken, id responseObject))success
failure:(void (^)(NSError *error))failure;
-
-- (void)acquireOAuthRequestTokenWithPath:(NSString *)path
- callback:(NSURL *)url
- accessMethod:(NSString *)accessMethod
- scope:(NSString *)scope
- success:(void (^)(AFOAuth1Token *requestToken))success
- failure:(void (^)(NSError *error))failure;
-
/**
*/
- (void)acquireOAuthRequestTokenWithPath:(NSString *)path
- callback:(NSURL *)url
+ callbackURL:(NSURL *)url
accessMethod:(NSString *)accessMethod
- success:(void (^)(AFOAuth1Token *requestToken))success
+ scope:(NSString *)scope
+ success:(void (^)(AFOAuth1Token *requestToken, id responseObject))success
failure:(void (^)(NSError *error))failure;
/**
@@ -116,7 +100,7 @@ typedef enum {
- (void)acquireOAuthAccessTokenWithPath:(NSString *)path
requestToken:(AFOAuth1Token *)requestToken
accessMethod:(NSString *)accessMethod
- success:(void (^)(AFOAuth1Token *accessToken))success
+ success:(void (^)(AFOAuth1Token *accessToken, id responseObject))success
failure:(void (^)(NSError *error))failure;
@end
View
38 AFOAuth1Client/AFOAuth1Client.m
@@ -253,35 +253,24 @@ - (void)authorizeUsingOAuthWithRequestTokenPath:(NSString *)requestTokenPath
callbackURL:(NSURL *)callbackURL
accessTokenPath:(NSString *)accessTokenPath
accessMethod:(NSString *)accessMethod
- success:(void (^)(AFOAuth1Token *accessToken))success
- failure:(void (^)(NSError *error))failure
-{
- [self authorizeUsingOAuthWithRequestTokenPath:requestTokenPath userAuthorizationPath:userAuthorizationPath callbackURL:callbackURL accessTokenPath:accessTokenPath accessMethod:accessMethod scope:nil success:success failure:failure];
-}
-
-- (void)authorizeUsingOAuthWithRequestTokenPath:(NSString *)requestTokenPath
- userAuthorizationPath:(NSString *)userAuthorizationPath
- callbackURL:(NSURL *)callbackURL
- accessTokenPath:(NSString *)accessTokenPath
- accessMethod:(NSString *)accessMethod
scope:(NSString *)scope
- success:(void (^)(AFOAuth1Token *accessToken))success
+ success:(void (^)(AFOAuth1Token *accessToken, id responseObject))success
failure:(void (^)(NSError *error))failure
{
- [self acquireOAuthRequestTokenWithPath:requestTokenPath callback:callbackURL accessMethod:(NSString *)accessMethod scope:scope success:^(AFOAuth1Token *requestToken) {
+ [self acquireOAuthRequestTokenWithPath:requestTokenPath callbackURL:callbackURL accessMethod:(NSString *)accessMethod scope:scope success:^(AFOAuth1Token *requestToken, id responseObject) {
__block AFOAuth1Token *currentRequestToken = requestToken;
[[NSNotificationCenter defaultCenter] addObserverForName:kAFApplicationLaunchedWithURLNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) {
NSURL *url = [[notification userInfo] valueForKey:kAFApplicationLaunchOptionsURLKey];
currentRequestToken.verifier = [AFParametersFromQueryString([url query]) valueForKey:@"oauth_verifier"];
- [self acquireOAuthAccessTokenWithPath:accessTokenPath requestToken:currentRequestToken accessMethod:accessMethod success:^(AFOAuth1Token * accessToken) {
+ [self acquireOAuthAccessTokenWithPath:accessTokenPath requestToken:currentRequestToken accessMethod:accessMethod success:^(AFOAuth1Token * accessToken, id responseObject) {
if (accessToken) {
self.accessToken = accessToken;
if (success) {
- success(accessToken);
+ success(accessToken, responseObject);
}
} else {
if (failure) {
@@ -312,19 +301,10 @@ - (void)authorizeUsingOAuthWithRequestTokenPath:(NSString *)requestTokenPath
}
- (void)acquireOAuthRequestTokenWithPath:(NSString *)path
- callback:(NSURL *)callbackURL
- accessMethod:(NSString *)accessMethod
- success:(void (^)(AFOAuth1Token *requestToken))success
- failure:(void (^)(NSError *error))failure
-{
- [self acquireOAuthRequestTokenWithPath:path callback:callbackURL accessMethod:accessMethod scope:nil success:success failure:failure];
-}
-
-- (void)acquireOAuthRequestTokenWithPath:(NSString *)path
- callback:(NSURL *)callbackURL
+ callbackURL:(NSURL *)callbackURL
accessMethod:(NSString *)accessMethod
scope:(NSString *)scope
- success:(void (^)(AFOAuth1Token *requestToken))success
+ success:(void (^)(AFOAuth1Token *requestToken, id responseObject))success
failure:(void (^)(NSError *error))failure
{
NSMutableDictionary *parameters = [[self OAuthParameters] mutableCopy];
@@ -339,7 +319,7 @@ - (void)acquireOAuthRequestTokenWithPath:(NSString *)path
AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
if (success) {
AFOAuth1Token *accessToken = [[AFOAuth1Token alloc] initWithQueryString:operation.responseString];
- success(accessToken);
+ success(accessToken, responseObject);
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
if (failure) {
@@ -353,7 +333,7 @@ - (void)acquireOAuthRequestTokenWithPath:(NSString *)path
- (void)acquireOAuthAccessTokenWithPath:(NSString *)path
requestToken:(AFOAuth1Token *)requestToken
accessMethod:(NSString *)accessMethod
- success:(void (^)(AFOAuth1Token *accessToken))success
+ success:(void (^)(AFOAuth1Token *accessToken, id responseObject))success
failure:(void (^)(NSError *error))failure
{
self.accessToken = requestToken;
@@ -367,7 +347,7 @@ - (void)acquireOAuthAccessTokenWithPath:(NSString *)path
AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
if (success) {
AFOAuth1Token *accessToken = [[AFOAuth1Token alloc] initWithQueryString:operation.responseString];
- success(accessToken);
+ success(accessToken, responseObject);
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
if (failure) {
View
2  Twitter OSX Example Client/Twitter OSX Example Client/AppDelegate.m
@@ -35,7 +35,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
self.twitterClient = [[AFOAuth1Client alloc] initWithBaseURL:[NSURL URLWithString:@"https://api.twitter.com/"] key:@"4oFCF0AjP4PQDUaCh5RQ" secret:@"NxAihESVsdUXSUxtHrml2VBHA0xKofYKmmGS01KaSs"];
[self.twitterClient registerHTTPOperationClass:[AFJSONRequestOperation class]];
- [self.twitterClient authorizeUsingOAuthWithRequestTokenPath:@"oauth/request_token" userAuthorizationPath:@"oauth/authorize" callbackURL:[NSURL URLWithString:@"af-twitter://success"] accessTokenPath:@"oauth/access_token" accessMethod:@"POST" success:^(AFOAuth1Token *accessToken) {
+ [self.twitterClient authorizeUsingOAuthWithRequestTokenPath:@"oauth/request_token" userAuthorizationPath:@"oauth/authorize" callbackURL:[NSURL URLWithString:@"af-twitter://success"] accessTokenPath:@"oauth/access_token" accessMethod:@"POST" scope:nil success:^(AFOAuth1Token *accessToken, id responseObject) {
NSLog(@"Success: %@", accessToken);
[self.twitterClient getPath:@"1/statuses/user_timeline.json" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
Please sign in to comment.
Something went wrong with that request. Please try again.