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

Pass response object of OAuth response #39

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions AFOAuth1Client/AFOAuth1Client.h 100644 → 100755
Expand Up @@ -81,7 +81,7 @@ typedef enum {
callbackURL:(NSURL *)callbackURL
accessTokenPath:(NSString *)accessTokenPath
accessMethod:(NSString *)accessMethod
success:(void (^)(AFOAuth1Token *accessToken))success
success:(void (^)(AFOAuth1Token *accessToken, id responseObject))success
failure:(void (^)(NSError *error))failure;

/**
Expand All @@ -90,7 +90,7 @@ typedef enum {
- (void)acquireOAuthRequestTokenWithPath:(NSString *)path
callback:(NSURL *)url
accessMethod:(NSString *)accessMethod
success:(void (^)(AFOAuth1Token *requestToken))success
success:(void (^)(AFOAuth1Token *requestToken, id responseObject))success
failure:(void (^)(NSError *error))failure;

/**
Expand All @@ -99,7 +99,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
Expand Down
18 changes: 9 additions & 9 deletions AFOAuth1Client/AFOAuth1Client.m 100644 → 100755
Expand Up @@ -252,21 +252,21 @@ - (void)authorizeUsingOAuthWithRequestTokenPath:(NSString *)requestTokenPath
callbackURL:(NSURL *)callbackURL
accessTokenPath:(NSString *)accessTokenPath
accessMethod:(NSString *)accessMethod
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 success:^(AFOAuth1Token *requestToken) {
[self acquireOAuthRequestTokenWithPath:requestTokenPath callback:callbackURL accessMethod:(NSString *)accessMethod 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) {
self.accessToken = accessToken;

if (success) {
success(accessToken);
success(accessToken, responseObject);
}
} failure:^(NSError *error) {
if (failure) {
Expand All @@ -292,7 +292,7 @@ - (void)authorizeUsingOAuthWithRequestTokenPath:(NSString *)requestTokenPath
- (void)acquireOAuthRequestTokenWithPath:(NSString *)path
callback:(NSURL *)callbackURL
accessMethod:(NSString *)accessMethod
success:(void (^)(AFOAuth1Token *requestToken))success
success:(void (^)(AFOAuth1Token *requestToken, id responseObject))success
failure:(void (^)(NSError *error))failure
{
NSMutableDictionary *parameters = [[self OAuthParameters] mutableCopy];
Expand All @@ -304,7 +304,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) {
Expand All @@ -318,7 +318,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;
Expand All @@ -332,7 +332,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) {
Expand All @@ -350,7 +350,7 @@ - (NSMutableURLRequest *)requestWithMethod:(NSString *)method
parameters:(NSDictionary *)parameters
{
NSMutableURLRequest *request = [super requestWithMethod:method path:path parameters:parameters];
[request setValue:[self authorizationHeaderForMethod:method path:path parameters:parameters] forHTTPHeaderField:@"Authorization"];
[request setValue:[self authorizationHeaderForMethod:method path:path parameters:parameters] forHTTPHeaderField:@"Authorization"];
[request setHTTPShouldHandleCookies:NO];

return request;
Expand Down