SimpleAuth is designed to do the hard work of social account login on iOS

Overview

SimpleAuth

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.

SimpleAuth currently has the following providers:

Installing

Install SimpleAuth with CocoaPods. For example, to use Facebook and Twitter authentication, add

pod 'SimpleAuth/Facebook'
pod 'SimpleAuth/Twitter'

to your Podfile.

Usage

Configuring and using SimpleAuth is easy:

// Somewhere in your app boot process
SimpleAuth.configuration()["twitter"] = [
    "consumer_key": "KEY",
    "consumer_secret": "SECRET"
]
// Authorize
func loginWithTwitter() {
    SimpleAuth.authorize("twitter", completion: { responseObject, error in
        println("Twitter login response: \(responseObject)")
    })
}

Implementing a Provider

The API for creating providers is pretty simple. Be sure to look at SimpleAuthProvider and SimpleAuthWebLoginViewController. These classes will help you simplify your authentiction process. Providers should be stored in Pod/Providers/ and have an appropriately named folder and sub spec. All providers are automatically registered with the framework. There are a handful of methods you'll need to implement:

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.

License

SimpleAuth is released under the MIT license.

Thanks

Special thanks to my friend @soffes for advising on the SimpleAuth API design.

Contributors

Comments
  • Facebook Login in ios application

    Facebook Login in ios application

    Hi, I implemented Instagram Login in my app , that worked like charm !! Thanks for it :) Now I'm implementing facebook login , I'm copying this code in my appdelegate( am I doing it right ?). SimpleAuth.configuration()["facebook"] = [ "app_id" : "" ] It is saying " Called Object type NSMutableDictionary is not a function or a function pointer " I'm going to test it on simulator , will it work ?

    opened by yugalkishoregoyal 23
  • Box

    Box

    Hey Caleb, would love for you to take a look

    I tested this successfully with the example app although setting up Box to work in an app requires a special redirect URI in the format boxsdk-YOUR_CLIENT_ID://boxsdkoauth2redirect (source)

    As you can see, we can get the redirect URI from the CLIENT_ID but I couldn't get this to work so for now, you have to set

        NSString *boxClientId = @"CLIENT_ID";
        SimpleAuth.configuration[@"box-web"] = @{
                                                 @"client_id":boxClientId,
                                                 @"client_secret":@"CLIENT_SECRET",
                                                 @"redirect_uri" : [NSString stringWithFormat:@"boxsdk-%@://boxsdkoauth2redirect", boxClientId],
                                                 };
    
    opened by dkhamsing 20
  • There is no class registered to handle Instagram requests. - Swift

    There is no class registered to handle Instagram requests. - Swift

    Hey Caleb,

    I am getting the following error when launching in Swift.

    Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'There is no class registered to handle Instagram requests."
    

    I understand (from reading one of your answers on teamtreehouse) that SimpleAuth cannot find the files associated with handling IG authentication. I have the authorisation command in my initial view controller class but I suspect that this has something to do with the fact that I may not have called the following right in my AppDelegate.swift

    SimpleAuth.configuration[@"instagram"] = @{
        @"client_id" : @"CLIENT_ID",
        SimpleAuthRedirectURIKey : @"https://mysite.com/auth/instagram/callback"
    };
    

    I couldn't figure out a way to write that in swift so I attempted to call it in a .m and .h files and bridge those into my project like so. Forgive me for the horrible coding I've never done Obj-C in my life as I am new to coding and attempted to copy off a tutorial.

    PhotoBombersHeader.h
    
    #ifndef Photo_Bombers_PhotoBombersHeader_h
    #define Photo_Bombers_PhotoBombersHeader_h
    
    #import <Foundation/Foundation.h>
    
    @interface  simpAuthConfiguration : NSObject
    
    @property (strong, nonatomic) id someProperty;
    
    - (void) someMethod;
    
    @end
    #endif
    
    PhotoBombersHeaderM.m
    
    #import <Foundation/Foundation.h>
    #import <SimpleAuth/SimpleAuth.h>
    
    
    @implementation simpAuthConfiguration : NSObject
    
    // This method is the one we will use to
    - (void) someMethod {
        SimpleAuth.configuration[@"instagram"] = @{
            @"client_id" : @"*******",
            SimpleAuthRedirectURIKey : @"https://www.google.com"
        };
    }
    
    @end
    

    And i would then call simpAuthConfiguration in my AppDelegate.swift after bridging PhotoBombersHeader.h so the methods could be used in my Swift project.

    TL;DR - Basically couldn't figure out a way to translate language and tried to do it a different way and it isn't really working, any chance you could help me out?

    Cheers, Jack

    opened by chahooo 12
  • Error on adding SimpleAuth

    Error on adding SimpleAuth

    On including SimpleAuth via Cocoapods, I am getting following error in Pods-Contakt-LlamaKit :

    error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: unknown option character `X' in: -Xlinker

    opened by gsrivast31 11
  • How to debug response null for facebook-web?

    How to debug response null for facebook-web?

    for https://www.facebook.com/dialog/oauth? in SimpleAuthFacebookWebLoginViewController.h. I try to debug the generated facebok oauth url string.

    What is the best way to debug so I know if the problem in SimpleAuthFacebookWebLoginViewController.h or in facebook setting? some facebok setting like redirect_uri? site_url? etc.

    from http://support.intenthq.com/support/articles/178390-creating-your-app-on-facebook-new-interface

    opened by steve21124 10
  • Some strange Major bug occuring

    Some strange Major bug occuring

    Hi @calebd

    Came back to SimpleAuth after long time. You have done major progress by the time for SimpleAuth. There's one strange bug happening though. Here's the scenario:

    1. Installed 2 application using SimpleAuth facebook
    2. Connected First application with facebook successfully
    3. In Second application If I disallow access or any other error occurs while connecting to facebook.
    4. The first application start returning NULL as response object. No matter what.

    I tried uninstalling both application. And installed first application again, but still the response object is NULL.

    Created completely 2 fresh application but the problem didn't resolve. The namespace are different, both facebook applications are also different.

    I deleted my account from Settings and installed the first application and then it starts working.

    Not sure why this is happening, have to look into code. But can you confirm this is happening or not?

    bug 
    opened by akashkamboj 9
  • Adding logout mechanism

    Adding logout mechanism

    Superb and really nice framework, I wish I would have find out this earlier, by the way can anyone enlighten me about which is the best way to implement logout mechanism ?

    opened by iamabhiee 9
  • Would be a lot better if you create a SimpleAuthUser

    Would be a lot better if you create a SimpleAuthUser

    @calebd Also it would be a lot better that you create a NSObject for SimpleAuthUser and fill the necessary properties in that. So in case someone requires a Facebook Access Token, expires at etc. it can be filled in the SimpleAuthUser class. What do you think?

    opened by akashkamboj 9
  • OneDrive

    OneDrive

    Hey Caleb, here's the OneDrive provider which has OAuth through Microsoft Live with a specific scope for storage permissions http://onedrive.github.io

    - isTargetRedirectURL: seems a bit fragile but it works in the example app

    I left out the Podfile.lock, I'm not sure how that thing is generated :smile:

    opened by dkhamsing 8
  • Twitter-web login is failed with

    Twitter-web login is failed with "NSErrorFailingURLKey=https://twitter.com/intent/sessions"

    I tried to login with Twitter and return responseObject nil then gives this error:

    Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0x15f8dd60 {NSErrorFailingURLKey=https://twitter.com/intent/sessions, NSErrorFailingURLStringKey=https://twitter.com/intent/sessions}

    opened by Elmundo 7
  • Swift Rewrite

    Swift Rewrite

    I have the following goals for a new version of SimpleAuth that solves many of the issues we see today:

    • Swift
    • Strongly typed provider configurations
    • Make SimpleAuthProvider a subclass of NSOperation
    • The SimpleAuth class will maintain an instance of NSOperationQueue to ensure serial operations
    • Favor direct provider interaction over the indirection that is used today
    • Keep existing API (deprecated)
    opened by calebd 7
  • setup web view through constraints in order to seamless support iPhone X

    setup web view through constraints in order to seamless support iPhone X

    Setup instagram authorizing controller web view via constraints in order to support iPhone X. Tested on simulators iPhone X iOS 11, iPhone 6 iOS 10/11.

    opened by gralexey 0
  • "facebook" error 102

    Error Domain=SimpleAuthErrorDomain Code=102 "(null)" UserInfo={NSUnderlyingError=0x174049d50 {Error Domain=com.apple.accounts Code=6 "(null)"}}

    Why i have this error?

    opened by serk87 1
  • bug using swift 3

    bug using swift 3

    please have a look at this thread

    http://stackoverflow.com/questions/40168448/swift-3-how-to-solve-ambiguous-use-of-authorize-completion/40169747#40169747

    the compiler in xcode 8, using swift 3 throws an error, if you want to use the following func:

    open class func authorize(_ provider: String!, completion: SimpleAuth.SimpleAuthRequestHandler!)

    problem is the following function:

    open class func authorize(_ provider: String!, options: [AnyHashable : Any]! = [:], completion: SimpleAuth.SimpleAuthRequestHandler!)

    because of = [:]

    opened by davidseek 2
  • Instagram App instead of webView

    Instagram App instead of webView

    I have just implemented SimpleAuth for Instagram, had to login and needed about 10 minutes to reset my PW since I didn't knew it anymore... I don't want to lose customers with the same issue...

    Is it possible to check, if the Instagram App is installed and make the auth request with the app? In Swift please.

    Help is very appreciated.

    opened by davidseek 0
  • SimpleAuthFoursquareWebLoginViewController#initialRequest method isn't loading parameters correctly

    SimpleAuthFoursquareWebLoginViewController#initialRequest method isn't loading parameters correctly

    So the parameters dictionary in the initialRequest method of SimpleAuthFoursquareWebLoginViewController keeps throwing the following error:

    *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'

    When I hardcode the values of parameters with my own client_id and redirect_uri everything works as expected. So it looks like the problem lies in retrieving the dictionary that is passed to SimpleAuth.configuration[@"foursquare-web"]; that is, self.options[@"client_id"] and self.options[SimpleAuthRedirectURIKey] are both returning nil values.

    Thanks

    opened by ghost 0
Releases(v0.3.2)
  • v0.3.2(Jan 28, 2014)

    Provider changes:

    • Instagram provider now accepts scope

    Internal changes:

    • Fix bug where tapping "Cancel" in any of the web view controllers would not result in appropriate errors being reported to the caller
    • Make system providers (Twitter and Facebook) behave more like other providers
    • Remove SimpleAuthSystemProvider class
    • Add category on ACAccountStore to assist with fetching system accounts
    Source code(tar.gz)
    Source code(zip)
  • v0.3.1(Jan 24, 2014)

    SimpleAuth 0.3.1 brings a set of new providers and minor changes to the internal API.

    New providers:

    • Meetup
    • Foursquare
    • Dropbox
    • Facebook web
    • Tumblr

    API Changes:

    • New class loader. Providers no longer need to register themselves with SimpleAuth. This is all done automatically.
    • Replace query string serialization with CMDQueryStringSerialization. Removes dependency on SAMCategories.
    • Internalize some logic for web view controllers to make that API easier to work with.
    • Bug fixes in providers.
    Source code(tar.gz)
    Source code(zip)
  • v0.3.0(Jan 21, 2014)

Owner
Caleb Davenport
Caleb Davenport
LoginKit is a quick and easy way to add Facebook and email Login/Signup UI to your app.

LoginKit About LoginKit is a quick and easy way to add Facebook and email Login/Signup UI to your app. If you need to quickly prototype an app, create

Icalia Labs 653 Dec 17, 2022
An poc to make a login using Auth0 in Swift

Swift-Auth0-poc This app is an poc to make a login using Auth0. If you want to try it yourself here is a small tutorial on how to do it. 1. Configure

Sem de Wilde 1 Jan 21, 2022
SwiftCoreDataLoginPage - Login and registration with core data

Login and Registration Page with CoreData In this basic project, which was used

Buse Köseoğlu 2 Aug 22, 2022
InstagramLogin allows iOS developers to authenticate users by their Instagram accounts.

InstagramLogin handles all the Instagram authentication process by showing a custom UIViewController with the login page and returning an access token that can be used to request data from Instagram.

Ander Goig 67 Aug 20, 2022
Easy to use OAuth 2 library for iOS, written in Swift.

Heimdallr Heimdallr is an OAuth 2.0 client specifically designed for easy usage. It currently supports the resource owner password credentials grant f

trivago N.V. 628 Oct 17, 2022
OAuth2 framework for macOS and iOS, written in Swift.

OAuth2 OAuth2 frameworks for macOS, iOS and tvOS written in Swift 5.0. ⤵️ Installation ?? Usage ?? Sample macOS app (with data loader examples) ?? Tec

Pascal Pfiffner 1.1k Jan 2, 2023
Swift based OAuth library for iOS

OAuthSwift Swift based OAuth library for iOS and macOS. Support OAuth1.0, OAuth2.0 Twitter, Flickr, Github, Instagram, Foursquare, Fitbit, Withings, L

OAuthSwift 3.1k Jan 3, 2023
A simple OAuth library for iOS with a built-in set of providers

SwiftyOAuth is a small OAuth library with a built-in set of providers and a nice API to add your owns. let instagram: Provider = .instagram(clientID:

Damien 477 Oct 15, 2022
A simple library to make authenticating tvOS apps easy via their iOS counterparts.

Voucher The new Apple TV is amazing but the keyboard input leaves a lot to be desired. Instead of making your users type credentials into their TV, yo

Riz 516 Nov 24, 2022
FCLAuthSwift is a Swift library for the Flow Client Library (FCL) that enables Flow wallet authentication on iOS devices.

FCLAuthSwift is a Swift library for the Flow Client Library (FCL) that enables Flow wallet authentication on iOS devices. Demo The demo a

Zed 3 May 2, 2022
A simple project for Face ID Authentication for iOS device using LocalAuthentication Framework

BiometricAuthentication This respository is a simple project for Face ID Authentication for iOS device using LocalAuthentication Framework and infoPli

Lee McCormick 0 Oct 23, 2021
Swift based OAuth library for iOS and macOS

OAuthSwift Swift based OAuth library for iOS and macOS. Support OAuth1.0, OAuth2.0 Twitter, Flickr, Github, Instagram, Foursquare, Fitbit, Withings, L

OAuthSwift 3.1k Jan 3, 2023
Krypton turns your iOS device into a WebAuthn/U2F Authenticator: strong, unphishable 2FA.

Krypton turns your iOS device into a WebAuthn/U2F Authenticator: strong, unphishable 2FA. Krypton implements the standardized FIDO Universal 2nd Facto

krypt.co 332 Nov 5, 2022
Social Media platform build with swiftUI and Firebase with google and apple account integration for Signing In Users

Social Media platform build with swiftUI and Firebase with google and apple account integration for Signing In Users . Providing Users availability to upload posts and images add caption allowing other users to comment , with Find section to explore new people , new stories , User Profile section to allow the user to take control of his account .

Devang Papinwar 2 Jul 11, 2022
HealthKit is notoriously hard to work with. Let's change that.

Health X Better interfacing with HealthKit HealthKit is notoriously hard to work with. Let's change that. Using Combine features like ObservableObject

Siddharth 1 Feb 17, 2022
Login-screen-UI - A simple iOS login screen written in Swift 5

This project has been updated to Swift 5 and Xcode 11.2 About This is a simple i

Kushal Shingote 2 Feb 4, 2022
Unified API Library for: Cloud Storage, Social Log-In, Social Interaction, Payment, Email, SMS, POIs, Video & Messaging.

Unified API Library for: Cloud Storage, Social Log-In, Social Interaction, Payment, Email, SMS, POIs, Video & Messaging. Included services are Dropbox, Google Drive, OneDrive, OneDrive for Business, Box, Egnyte, PayPal, Stripe, Google Places, Foursquare, Yelp, YouTube, Vimeo, Twitch, Facebook Messenger, Telegram, Line, Viber, Facebook, GitHub, Google+, LinkedIn, Slack, Twitter, Windows Live, Yahoo, Mailjet, Sendgrid, Twilio, Nexmo, Twizo.

CloudRail 195 Nov 29, 2021
A low-maintenance, simple framework for a snapshot testing, which takes into account a snapshot difference factor (must have if you're using CI).

CornSnapshotTesting A low-maintenance, simple framework for a snapshot testing, which takes into account a snapshot difference factor (must have if yo

Rita 2 Nov 29, 2021
A script for focusing on work, blocking non-work stuff.

A script for focusing on work, blocking non-work stuff. The idea is to forbid mindless app/website context-switching while you're focused. Once you're

null 3 Jan 23, 2022
Work-hours-mac - Simple app that tracks your work hours from the status bar

Track Your Work Hours Simple app that tracks your work hours from status bar. Fe

Niteo 44 Dec 2, 2022