Permalink
Browse files

Merge branch 'bug/two-legged' of git://github.com/madninja/AFOAuth1Cl…

…ient into madninja-bug/two-legged

Conflicts:
	AFOAuth1Client/AFOAuth1Client.m
  • Loading branch information...
2 parents 27b32cd + abc1b78 commit 385fcca5fd24594df07e47e70601fd2788c8283c @mattt mattt committed Mar 5, 2013
Showing with 19 additions and 9 deletions.
  1. +19 −9 AFOAuth1Client/AFOAuth1Client.m
@@ -330,18 +330,28 @@ - (NSMutableURLRequest *)requestWithMethod:(NSString *)method
parameters:(NSDictionary *)parameters
{
NSMutableDictionary *mutableParameters = parameters ? [parameters mutableCopy] : [NSMutableDictionary dictionary];
+ NSMutableDictionary *mutableAuthorizationParameters = [NSMutableDictionary dictionary];
- if (self.accessToken) {
- [mutableParameters addEntriesFromDictionary:[self OAuthParameters]];
- [mutableParameters setValue:self.accessToken.key forKey:@"oauth_token"];
+ if (self.key && self.secret) {
+ [mutableAuthorizationParameters addEntriesFromDictionary:[self OAuthParameters]];
+ if (self.accessToken) {
+ [mutableAuthorizationParameters setValue:self.accessToken.key forKey:@"oauth_token"];
+ }
}
-
- [mutableParameters setValue:[self OAuthSignatureForMethod:method path:path parameters:mutableParameters token:self.accessToken] forKey:@"oauth_signature"];
-
- NSMutableURLRequest *request = [super requestWithMethod:method path:path parameters:mutableParameters];
- [request setValue:[self authorizationHeaderForParameters:mutableParameters] forHTTPHeaderField:@"Authorization"];
+
+ [mutableParameters enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
+ if ([key isKindOfClass:[NSString class]] && [key hasPrefix:@"oauth_"]) {
+ [mutableAuthorizationParameters setValue:obj forKey:key];
+ }
+ }];
+
+ [mutableParameters addEntriesFromDictionary:mutableAuthorizationParameters];
+ [mutableAuthorizationParameters setValue:[self OAuthSignatureForMethod:method path:path parameters:mutableParameters token:self.accessToken] forKey:@"oauth_signature"];
+
+ NSMutableURLRequest *request = [super requestWithMethod:method path:path parameters:parameters];
+ [request setValue:[self authorizationHeaderForParameters:mutableAuthorizationParameters] forHTTPHeaderField:@"Authorization"];
[request setHTTPShouldHandleCookies:NO];
-
+
return request;
}

0 comments on commit 385fcca

Please sign in to comment.