diff --git a/AFOAuth2Manager/AFOAuth2Manager.h b/AFOAuth2Manager/AFOAuth2Manager.h index f6927dd7..ba2c2a95 100644 --- a/AFOAuth2Manager/AFOAuth2Manager.h +++ b/AFOAuth2Manager/AFOAuth2Manager.h @@ -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. @@ -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. @@ -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. @@ -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. @@ -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 diff --git a/AFOAuth2Manager/AFOAuth2Manager.m b/AFOAuth2Manager/AFOAuth2Manager.m index 88d83f11..55c74331 100644 --- a/AFOAuth2Manager/AFOAuth2Manager.m +++ b/AFOAuth2Manager/AFOAuth2Manager.m @@ -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); @@ -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"]; @@ -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); @@ -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); @@ -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) { @@ -232,7 +232,7 @@ - (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString if ([responseObject valueForKey:@"error"]) { if (failure) { - failure(AFErrorFromRFC6749Section5_2Error(responseObject)); + failure(task, AFErrorFromRFC6749Section5_2Error(responseObject)); } } @@ -265,7 +265,7 @@ - (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { if (failure) { - failure(error); + failure(task, error); } }];