Skip to content
Browse files

added an oauth authorization header generator that takes into account…

… the 'oauth_callback' parameter
  • Loading branch information...
1 parent e499a07 commit b01d73d3ab16ca174b97b7262aa40ab02b978576 Andrew Farmer committed
Showing with 18 additions and 3 deletions.
  1. +10 −1 OAuthCore.h
  2. +8 −2 OAuthCore.m
View
11 OAuthCore.h
@@ -7,10 +7,19 @@
#import <Foundation/Foundation.h>
-extern NSString *OAuthorizationHeader(NSURL *url,
+extern NSString *OAuthorizationHeader(NSURL *url,
NSString *method,
NSData *body,
NSString *_oAuthConsumerKey,
NSString *_oAuthConsumerSecret,
NSString *_oAuthToken,
NSString *_oAuthTokenSecret);
+
+extern NSString *OAuthorizationHeaderWithCallback(NSURL *url,
+ NSString *method,
+ NSData *body,
+ NSString *_oAuthConsumerKey,
+ NSString *_oAuthConsumerSecret,
+ NSString *_oAuthToken,
+ NSString *_oAuthTokenSecret,
+ NSString *_oAuthCallback);
View
10 OAuthCore.m
@@ -27,7 +27,11 @@ static NSInteger SortParameter(NSString *key1, NSString *key2, void *context) {
return [NSData dataWithBytes:buf length:CC_SHA1_DIGEST_LENGTH];
}
-NSString *OAuthorizationHeader(NSURL *url, NSString *method, NSData *body, NSString *_oAuthConsumerKey, NSString *_oAuthConsumerSecret, NSString *_oAuthToken, NSString *_oAuthTokenSecret)
+NSString *OAuthorizationHeader(NSURL *url, NSString *method, NSData *body, NSString *_oAuthConsumerKey, NSString *_oAuthConsumerSecret, NSString *_oAuthToken, NSString *_oAuthTokenSecret) {
+ return OAuthorizationHeaderWithCallback(url, method, body, _oAuthConsumerKey, _oAuthConsumerSecret, _oAuthToken, _oAuthTokenSecret, nil);
+}
+
+NSString *OAuthorizationHeaderWithCallback(NSURL *url, NSString *method, NSData *body, NSString *_oAuthConsumerKey, NSString *_oAuthConsumerSecret, NSString *_oAuthToken, NSString *_oAuthTokenSecret, NSString *_oAuthCallback)
{
NSString *_oAuthNonce = [NSString ab_GUID];
NSString *_oAuthTimestamp = [NSString stringWithFormat:@"%d", (int)[[NSDate date] timeIntervalSince1970]];
@@ -42,7 +46,9 @@ static NSInteger SortParameter(NSString *key1, NSString *key2, void *context) {
[oAuthAuthorizationParameters setObject:_oAuthConsumerKey forKey:@"oauth_consumer_key"];
if(_oAuthToken)
[oAuthAuthorizationParameters setObject:_oAuthToken forKey:@"oauth_token"];
-
+ if (_oAuthCallback)
+ [oAuthAuthorizationParameters setObject:_oAuthCallback forKey:@"oauth_callback"];
+
// get query and body parameters
NSDictionary *additionalQueryParameters = [NSURL ab_parseURLQueryString:[url query]];
NSDictionary *additionalBodyParameters = nil;

0 comments on commit b01d73d

Please sign in to comment.
Something went wrong with that request. Please try again.