Skip to content

Commit

Permalink
Move secret and ke outside library
Browse files Browse the repository at this point in the history
  • Loading branch information
Constantine Fry committed Jul 7, 2013
1 parent d171593 commit 6f66a24
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
6 changes: 6 additions & 0 deletions Foursquare2-iOS/Classes/FSAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "FSAppDelegate.h"
#import "NearbyVenuesViewController.h"
#import "Foursquare2.h"

@implementation FSAppDelegate

Expand All @@ -19,6 +20,11 @@ @implementation FSAppDelegate
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

[Foursquare2 setupFoursquareWithKey:@"5P1OVCFK0CCVCQ5GBBCWRFGUVNX5R4WGKHL2DGJGZ32FDFKT"
secret:@"UPZJO0A0XL44IHCD1KQBMAYGCZ45Z03BORJZZJXELPWHPSAR"
callbackURL:@"app://testapp123"];

window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIViewController *c = [[NearbyVenuesViewController alloc]init];
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:c];
Expand Down
19 changes: 4 additions & 15 deletions Foursquare2/Foursquare2.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,7 @@
#import "FSWebLogin.h"
#endif

//1
#ifndef FS2_OAUTH_KEY
#define FS2_OAUTH_KEY (@"5P1OVCFK0CCVCQ5GBBCWRFGUVNX5R4WGKHL2DGJGZ32FDFKT")
#endif

#ifndef FS2_OAUTH_SECRET
#define FS2_OAUTH_SECRET (@"UPZJO0A0XL44IHCD1KQBMAYGCZ45Z03BORJZZJXELPWHPSAR")
#endif

//2, don't forget to added app url in your info plist file CFBundleURLTypes
#ifndef FS2_REDIRECT_URL
#define FS2_REDIRECT_URL @"app://testapp123"
#endif

//3 update this date to use up-to-date Foursquare API
//update this date to use up-to-date Foursquare API
#ifndef FS2_API_VERSION
#define FS2_API_VERSION (@"20130117")
#endif
Expand Down Expand Up @@ -74,6 +60,9 @@ typedef enum {
+(BOOL)isAuthorized;
#pragma mark -

+ (void)setupFoursquareWithKey:(NSString *)key
secret:(NSString *)secret
callbackURL:(NSString *)callbackURL;
#pragma mark ---------------------------- Users ------------------------------------------------------------------------
+(void)authorizeWithCallback:(Foursquare2Callback)callback;

Expand Down
21 changes: 18 additions & 3 deletions Foursquare2/Foursquare2.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,18 @@ + (void)initialize
NSUserDefaults *usDef = [NSUserDefaults standardUserDefaults];
if ([usDef objectForKey:@"access_token2"] != nil) {
[self classAttributes][@"access_token"] = [usDef objectForKey:@"access_token2"];

}
}

+ (void)setupFoursquareWithKey:(NSString *)key
secret:(NSString *)secret
callbackURL:(NSString *)callbackURL {
[self classAttributes][@"FOURSQUARE_OAUTH_KEY"] = key;
[self classAttributes][@"FOURSQUARE_OAUTH_SECRET"] = secret;
[self classAttributes][@"FOURSQUARE_CALLBACK_URL"] = callbackURL;
}



+ (void)setBaseURL:(NSString *)uri {
Expand Down Expand Up @@ -981,8 +990,11 @@ + (NSString *)constructRequestUrlForMethod:(NSString *)methodName
NSMutableString *paramStr = [NSMutableString stringWithString: [self classAttributes][@"FS2_API_BaseUrl"]];

[paramStr appendString:methodName];
[paramStr appendFormat:@"?client_id=%@",FS2_OAUTH_KEY];
[paramStr appendFormat:@"&client_secret=%@",FS2_OAUTH_SECRET];
NSDictionary *dic = [self classAttributes];
NSString *key = dic[@"FOURSQUARE_OAUTH_KEY"];
NSString *secret = dic[@"FOURSQUARE_OAUTH_SECRET"];
[paramStr appendFormat:@"?client_id=%@",key];
[paramStr appendFormat:@"&client_secret=%@",secret];
[paramStr appendFormat:@"&v=%@",FS2_API_VERSION];
NSLocale *locale = [NSLocale currentLocale];
NSString *countryCode = [locale objectForKey: NSLocaleLanguageCode];
Expand Down Expand Up @@ -1146,7 +1158,10 @@ - (void) uploadPhoto:(NSString *)methodName
Foursquare2Callback authorizeCallbackDelegate;
+(void)authorizeWithCallback:(Foursquare2Callback)callback{
authorizeCallbackDelegate = [callback copy];
NSString *url = [NSString stringWithFormat:@"https://foursquare.com/oauth2/authenticate?client_id=%@&response_type=token&redirect_uri=%@",FS2_OAUTH_KEY,FS2_REDIRECT_URL];
NSDictionary *dic = [self classAttributes];
NSString *key = dic[@"FOURSQUARE_OAUTH_KEY"];
NSString *callbackURL = dic[@"FOURSQUARE_CALLBACK_URL"];
NSString *url = [NSString stringWithFormat:@"https://foursquare.com/oauth2/authenticate?client_id=%@&response_type=token&redirect_uri=%@",key,callbackURL];
FSWebLogin *loginCon = [[FSWebLogin alloc] initWithUrl:url];
loginCon.delegate = self;
loginCon.selector = @selector(done:);
Expand Down

0 comments on commit 6f66a24

Please sign in to comment.