Skip to content

timonus/foursquare-ios-oauth

 
 

Repository files navigation

FSOAuth / TJFoursquareAuthentication

This is a hard fork of the FSOAuth project. While FSOAuth uses older APIs and is targeted at mass usage even in older clients, TJFoursquareAuthentication was rewritten to leverage new APIs and be a bit cleaner.

Usage

  1. You'll need to register a URL scheme for your app.
  2. You'll need to register your app in the Foursquare developer portal as described in FSOAuth's instructions. This will yield a client identifier and client secret for your app. You should use the URL scheme from step 1 with a unique path, I recommend something like your-apps-url-scheme://fsoauth.
  3. Add foursquareauth to your app's info.plist's LSApplicationQueriesSchemes array. (Optional, but provides a better experience for those running OS versions prior to iOS 10.0).
  4. Before you can authenticate, you should include a call to +tryHandleAuthenticationCallbackWithURL: in your app delegate's -application:openURL:options: implementation like so.
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options
{
    if ([TJFoursquareAuthentication tryHandleAuthenticationCallbackWithURL:url]) {
        // This is an auth callback, bail.
        return YES;
    } else {
        // Carry on with other URL handling
    }
}
  1. To initiate authentication, call +authenticateWithClientIdentifier:redirectURI:clientSecret:completion: passing in the client identifier, client secret, and redirect URI you received from step 2.
  2. Once complete, the completion block will be invoked on the main queue. Upon success, accessToken will be populated in this block.

Notes

  • TJFoursquareAuthentication is compatible with iOS 8 and above.
  • TJFoursquareAuthentication supports app-to-app auth with the Foursquare app.
  • TJFoursquareAuthentication will fall back to using ASWebAuthenticationSession or SFAuthenticationSession depending on iOS version if app-to-app auth isn't available. On older iOS versions it will launch Safari.app to perform auth.

Packages

No packages published

Languages

  • Objective-C 97.7%
  • Ruby 2.3%