Skip to content
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
21 changes: 21 additions & 0 deletions AFXAuthClient/AFXAuthClient.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,27 @@ -(void)authorizeUsingXAuthWithAccessTokenPath:(NSString *)accessTokenPath

- (NSMutableDictionary *)authorizationHeaderWithRequest:(NSURLRequest *)request parameters:(NSDictionary *)parameters
{
// use parameters for signature only if "application/x-www-form-urlencoded" (OAuth spec 9.1.1)
if (self.parameterEncoding != AFFormURLParameterEncoding) {
parameters = nil;
}
// get parameters from query string as well (OAuth spec 9.1.1)
NSMutableDictionary *mutableParameters = [parameters mutableCopy];
// make sure we have a parameters dictionary to add objects
if (mutableParameters == nil) {
mutableParameters = [[NSMutableDictionary alloc] init];
}
NSArray *queryParameters = [[[request URL] query] componentsSeparatedByString:@"&"];
for (NSString *parameter in queryParameters) {
// we support single value parameters
NSMutableArray *paramArray = [[parameter componentsSeparatedByString:@"="] mutableCopy];
NSString *key = [paramArray objectAtIndex:0];
[paramArray removeObjectAtIndex:0];
NSString *value = [paramArray componentsJoinedByString:@"="];
[mutableParameters setObject:value forKey:key];
}
parameters = mutableParameters;

NSMutableDictionary *authorizationHeader = [[NSMutableDictionary alloc] initWithDictionary:@{@"oauth_nonce": _nonce,
@"oauth_signature_method": @"HMAC-SHA1",
@"oauth_timestamp": _timestamp,
Expand Down