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

Commit 54f07d4

Browse files
committed
Pass NSURLSessionDataTask as block parameter
1 parent 146bfa1 commit 54f07d4

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

AFOAuth2Manager/AFOAuth2Manager.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ NS_ASSUME_NONNULL_BEGIN
107107
password:(NSString *)password
108108
scope:(nullable NSString *)scope
109109
success:(void (^)(AFOAuthCredential *credential))success
110-
failure:(void (^)(NSError *error))failure;
110+
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
111111

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

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

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

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

164164
@end
165165

AFOAuth2Manager/AFOAuth2Manager.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ - (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
144144
password:(NSString *)password
145145
scope:(NSString *)scope
146146
success:(void (^)(AFOAuthCredential * _Nonnull))success
147-
failure:(void (^)(NSError * _Nonnull))failure {
147+
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull))failure {
148148
NSParameterAssert(username);
149149
NSParameterAssert(password);
150150

@@ -163,7 +163,7 @@ - (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
163163
- (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
164164
scope:(NSString *)scope
165165
success:(void (^)(AFOAuthCredential * _Nonnull))success
166-
failure:(void (^)(NSError * _Nonnull))failure {
166+
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull))failure {
167167

168168
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
169169
[parameters setValue:kAFOAuthClientCredentialsGrantType forKey:@"grant_type"];
@@ -179,7 +179,7 @@ - (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
179179
- (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
180180
refreshToken:(NSString *)refreshToken
181181
success:(void (^)(AFOAuthCredential *credential))success
182-
failure:(void (^)(NSError *error))failure
182+
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure
183183
{
184184
NSParameterAssert(refreshToken);
185185

@@ -195,7 +195,7 @@ - (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
195195
code:(NSString *)code
196196
redirectURI:(NSString *)uri
197197
success:(void (^)(AFOAuthCredential *credential))success
198-
failure:(void (^)(NSError *error))failure
198+
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure
199199
{
200200
NSParameterAssert(code);
201201
NSParameterAssert(uri);
@@ -212,7 +212,7 @@ - (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
212212
- (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
213213
parameters:(NSDictionary *)parameters
214214
success:(void (^)(AFOAuthCredential *credential))success
215-
failure:(void (^)(NSError *error))failure
215+
failure:(void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure
216216
{
217217
NSMutableDictionary *mutableParameters = [NSMutableDictionary dictionaryWithDictionary:parameters];
218218
if (!self.useHTTPBasicAuthentication) {
@@ -232,7 +232,7 @@ - (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
232232

233233
if ([responseObject valueForKey:@"error"]) {
234234
if (failure) {
235-
failure(AFErrorFromRFC6749Section5_2Error(responseObject));
235+
failure(task, AFErrorFromRFC6749Section5_2Error(responseObject));
236236
}
237237
}
238238

@@ -265,7 +265,7 @@ - (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
265265

266266
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
267267
if (failure) {
268-
failure(error);
268+
failure(task, error);
269269
}
270270
}];
271271

0 commit comments

Comments
 (0)