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

Commit

Permalink
Pass NSURLSessionDataTask as block parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
nickhrsn committed Jul 11, 2019
1 parent 146bfa1 commit 54f07d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
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

0 comments on commit 54f07d4

Please sign in to comment.