Skip to content
This repository was archived by the owner on Jan 17, 2023. It is now read-only.
Open
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
9 changes: 5 additions & 4 deletions AFOAuth2Manager/AFOAuth2Manager.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ - (id)initWithBaseURL:(NSURL *)url
clientID:(NSString *)clientID
secret:(NSString *)secret {
NSParameterAssert(url);
NSParameterAssert(clientID);
NSParameterAssert(secret);

self = [super initWithBaseURL:url sessionConfiguration:configuration];
if (!self) {
Expand All @@ -123,9 +121,9 @@ - (void)setUseHTTPBasicAuthentication:(BOOL)useHTTPBasicAuthentication {
_useHTTPBasicAuthentication = useHTTPBasicAuthentication;

if (self.useHTTPBasicAuthentication) {
[self.requestSerializer setAuthorizationHeaderFieldWithUsername:self.clientID password:self.secret];
} else {
[self.requestSerializer setValue:nil forHTTPHeaderField:@"Authorization"];
} else {
[self.requestSerializer setAuthorizationHeaderFieldWithUsername:self.clientID password:self.secret];
}
}

Expand Down Expand Up @@ -216,6 +214,9 @@ - (NSURLSessionTask *)authenticateUsingOAuthWithURLString:(NSString *)URLString
{
NSMutableDictionary *mutableParameters = [NSMutableDictionary dictionaryWithDictionary:parameters];
if (!self.useHTTPBasicAuthentication) {
NSParameterAssert(self.clientID);
NSParameterAssert(self.secret);

mutableParameters[@"client_id"] = self.clientID;
mutableParameters[@"client_secret"] = self.secret;
}
Expand Down