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

Return AFHTTPRequestOperation in failure blocks. #111

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions AFOAuth2Manager/AFOAuth2Manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ NS_ASSUME_NONNULL_BEGIN
password:(NSString *)password
scope:(nullable NSString *)scope
success:(void (^)(AFOAuthCredential *credential))success
failure:(void (^)(NSError *error))failure;
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;

/**
Creates and enqueues an `NSURLSessionTask` to authenticate against the server with a designated scope.
Expand All @@ -120,7 +120,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
scope:(nullable NSString *)scope
success:(void (^)(AFOAuthCredential *credential))success
failure:(void (^)(NSError *error))failure;
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;

/**
Creates and enqueues an `NSURLSessionTask` to authenticate against the server using the specified refresh token.
Expand All @@ -132,7 +132,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
refreshToken:(NSString *)refreshToken
success:(void (^)(AFOAuthCredential *credential))success
failure:(void (^)(NSError *error))failure;
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;

/**
Creates and enqueues an `NSURLSessionTask` to authenticate against the server with an authorization code, redirecting to a specified URI upon successful authentication.
Expand All @@ -146,7 +146,7 @@ NS_ASSUME_NONNULL_BEGIN
code:(NSString *)code
redirectURI:(NSString *)uri
success:(void (^)(AFOAuthCredential *credential))success
failure:(void (^)(NSError *error))failure;
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;

/**
Creates and enqueues an `NSURLSessionTask` to authenticate against the server with the specified parameters.
Expand All @@ -159,7 +159,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
parameters:(NSDictionary *)parameters
success:(void (^)(AFOAuthCredential *credential))success
failure:(void (^)(NSError *error))failure;
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;

@end

Expand Down
14 changes: 7 additions & 7 deletions AFOAuth2Manager/AFOAuth2Manager.m
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ - (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
password:(NSString *)password
scope:(NSString *)scope
success:(void (^)(AFOAuthCredential * _Nonnull))success
failure:(void (^)(NSError * _Nonnull))failure {
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull))failure {
NSParameterAssert(username);
NSParameterAssert(password);

Expand All @@ -163,7 +163,7 @@ - (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
- (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
scope:(NSString *)scope
success:(void (^)(AFOAuthCredential * _Nonnull))success
failure:(void (^)(NSError * _Nonnull))failure {
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull))failure {

NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
[parameters setValue:kAFOAuthClientCredentialsGrantType forKey:@"grant_type"];
Expand All @@ -179,7 +179,7 @@ - (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
- (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
refreshToken:(NSString *)refreshToken
success:(void (^)(AFOAuthCredential *credential))success
failure:(void (^)(NSError *error))failure
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure
{
NSParameterAssert(refreshToken);

Expand All @@ -195,7 +195,7 @@ - (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
code:(NSString *)code
redirectURI:(NSString *)uri
success:(void (^)(AFOAuthCredential *credential))success
failure:(void (^)(NSError *error))failure
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure
{
NSParameterAssert(code);
NSParameterAssert(uri);
Expand All @@ -212,7 +212,7 @@ - (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
- (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
parameters:(NSDictionary *)parameters
success:(void (^)(AFOAuthCredential *credential))success
failure:(void (^)(NSError *error))failure
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure
{
NSMutableDictionary *mutableParameters = [NSMutableDictionary dictionaryWithDictionary:parameters];
if (!self.useHTTPBasicAuthentication) {
Expand All @@ -232,7 +232,7 @@ - (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString

if ([responseObject valueForKey:@"error"]) {
if (failure) {
failure(AFErrorFromRFC6749Section5_2Error(responseObject));
failure(task, AFErrorFromRFC6749Section5_2Error(responseObject));
}
}

Expand Down Expand Up @@ -265,7 +265,7 @@ - (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString

} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
if (failure) {
failure(error);
failure(task, error);
}
}];

Expand Down