Permalink
Browse files

Add consumer key & shared secret for OAuth signing.

  • Loading branch information...
lenards committed Feb 7, 2012
1 parent 1ea4af0 commit 28be81e58feaf734a18a4ddd534e8ad132206181
Showing with 34 additions and 2 deletions.
  1. +9 −2 libechonest/src/ENAPI.h
  2. +25 −0 libechonest/src/ENAPI.m
View
@@ -36,11 +36,18 @@ extern NSString * const ENSortWeight;
extern NSString * const ENSortFrequency;
@interface ENAPI : NSObject {
-
+
}
+ (void)initWithApiKey:(NSString *)apiKey;
+/**
+ * Consumer key and shared secret are required if calling OAuth secured endpoints. Example: "sandbox/access"
+ */
++ (void)initWithApiKey:(NSString *)apiKey ConsumerKey:(NSString *)consumerKey AndSharedSecret:(NSString *)secret;
+ (NSString *)apiKey;
-
++ (NSString *)consumerKey;
++ (void)setConsumerKey:(NSString *)key;
++ (NSString *)sharedSecret;
++ (void)setSharedSecret:(NSString *)secret;
@end
View
@@ -26,15 +26,40 @@
NSString * const ENSortFrequency = @"frequency";
static NSString *EN_API_KEY = nil;
+static NSString *EN_CONSUMER_KEY = nil;
+static NSString *EN_SHARED_SECRET = nil;
@implementation ENAPI
+ (void)initWithApiKey:(NSString *)apiKey {
EN_API_KEY = [apiKey retain];
}
++ (void)initWithApiKey:(NSString *)apiKey ConsumerKey:(NSString *)consumerKey
+ AndSharedSecret:(NSString *)secret {
+ [ENAPI initWithApiKey:apiKey];
+ [ENAPI setConsumerKey:consumerKey];
+ [ENAPI setSharedSecret:secret];
+}
+
+ (NSString *)apiKey {
return EN_API_KEY;
}
++ (NSString *)consumerKey {
+ return EN_CONSUMER_KEY;
+}
+
++ (void)setConsumerKey:(NSString *)key {
+ EN_CONSUMER_KEY = [key retain];
+}
+
++ (NSString *)sharedSecret {
+ return EN_SHARED_SECRET;
+}
+
++ (void)setSharedSecret:(NSString *)secret {
+ EN_SHARED_SECRET = [secret retain];
+}
+
@end

0 comments on commit 28be81e

Please sign in to comment.