SimpleAuth is designed to do the hard work of social account login on iOS. It has a small set of public APIs backed by a set of "providers" that implement the functionality needed to communicate with various social services. You can read more about it here.
SimpleAuth currently has the following providers:
- Facebook (system)
- Twitter (system)
- Twitter web
I would like to have:
- Twitter xauth
- Tumblr xauth
- GitHub
- Foursquare
- Dropbox
- App Dot Net
- Facebook web
- Tumblr web
Install SimpleAuth with CocoaPods. For example, to use Facebook and Twitter authentication, add
pod 'SimpleAuth/Facebook'
pod 'SimpleAuth/Twitter'
to your Podfile
.
Configuring and using SimpleAuth is easy:
// Somewhere in your app boot process
SimpleAuth.configuration[@"twitter"] = @{
@"consumer_key" : @"KEY",
@"consumer_secret" : @"SECRET"
};
// Authorize
- (void)loginWithTwitter {
[SimpleAuth authorize:@"twitter" completion:^(id responseObject, NSError *error) {
NSLog(@"%@", responseObject);
}];
}
The API for creating providers is pretty simple. Providers should be stored in Providers/
and have an appropriately named folder and sub spec. There are a handful of methods you'll need to implement:
Register your provider with SimpleAuth:
+ (void)load {
@autoreleasepool {
[SimpleAuth registerProviderClass:self];
}
}
Let SimpleAuth know what type of provider you are registering:
+ (NSString *)type {
return @"facebook";
}
Optionally, you may return a set of default options for all authorization options to use:
+ (NSDictionary *)defaultOptions {
return @{
@"permissions" : @[ @"email" ]
};
}
Finally, provide a method for handling authorization:
- (void)authorizeWithCompletion:(SimpleAuthRequestHandler)completion {
// Use values in self.options to customize behavior
// Perform authentication
// Call the completion
}
The rest is up to you! I welcome contributions to SimpleAuth, both improvements to the library itself and new providers.
SimpleAuth is released under the MIT license.
Special thanks to my friend @soffes for advising on the SimpleAuth API design.