AuthorizeMe: the iOS Library for Social Login

Login with social networks like Google and Facebook is vital to many apps because users don’t want to spend their time entering usernames and passwords. It’s proven that social logins reduce user friction and cart abandonment on ecommerce services. That’s why business owners are concerned with enabling users to log in with social networks.

To implement social login, developers often resort to ready-made libraries. For example, our iOS team has been using the SimpleAuth library for a while. However, despite the advantages of ready-made solutions (saving time), they don’t always meet our requirements. That’s why we decided to create an analogue of SimpleAuth, only better.

This is why we developed AuthorizeMe ‒ a library that enables iOS developers to implement social login features in a few steps.

What is AuthorizeMe?

AuthorizeMe is a library for iOS that implements login via Facebook, Google, LinkedIn, Instagram, and Twitter. The library contains the source code with providers for each social network. Providers retrieve user credentials (logins and passwords) to provide users with tokens that give access to social network data.

Advantages of AuthorizeMe

The features of AuthorizeMe are built on top of SimpleAuth’s functionality. Put simply, we listed the drawbacks of SimpleAuth and got rid of them when developing the AuthorizeMe library. Here’s what we got.

No Dependencies

Experienced developers know that dependencies are a bad practice that causes programmers to tweak their code every time there’s an update to a dependency.

For example, let’s say we have an A-library that depends on the B-dependency (for example, the B-library). The next time the developers of B-library make modifications, the developers of A-library will have to rewrite their code so it complies with the latest version of B-library. Consequently, developers that use A-library might need to rewrite their code because of these changes to A-library.

SimpleAuth is dependant on five other libraries, using only a few methods from each library. Such use of resources is unreasonable.

Written in Swift

AuthorizeMe is written in Swift, a state-of-the art programming language presented by Apple in 2014. Swift was designed as an alternative to Objective-C, which prevailed in iOS development at the time. Today, Swift is constantly gaining popularity and is predicted to fully replace its rival, Objective-C.

Plenty of iOS applications for top-notch products like Firefox, WordPress, Hacker News, SoundCloud, and Artsy are built with Swift. Lyft got on board with Swift as well: in 2015, Lyft rewrote their app in Swift (the initial Lyft app was written in Objective-C).

Advantages of Swift over Objective-C include:

Better safety. Swift doesn’t use pointers as Objective-C does, and is more resilient to invalid code.

Shorter TTM (Time to Market). Swift helps startups reduce time to market by introducing package managers ‒ tools that speed up the process of assembling an app.

Better readability. Swift resembles regular English just like Ruby, Python, and Java do. That’s why its syntax is easy to read and learn.

Interactivity. With Swift Playgrounds, developers can rapidly visualize their code and check if everything is correct. Playgrounds tools allow for various experiments without having to compile code.

Considering that many existing projects have switched to Swift while new projects prefer this language over Objective-C, we decided to write our library in Swift, unlike SimpleAuth which is written in Objective-C.

Ability to Add Custom Providers

AuthorizeMe is built on top of class providers that implement authorization functionality. Currently, the library supports five predetermined providers for the most popular networks including Google and Facebook.

But if you can’t find a social network or service (like Dropbox or Foursquare) that you’d like your users to be able to authorize with, that not an issue. With AuthorizeMe, you’re able to create custom providers for any service. Simply use the API for the service you’d like to integrate with AuthorizeMe.

Detailed Wikis

GitHub contributors often get carried away with writing code. As a result, other important project components like documentation, wikis, examples, and manuals are often overlooked. In fact, a recent survey shows that 93% of respondents name incomplete or out-of-date documentation as a top problem of open source software.

The AuthorizeMe library boasts comprehensive wikis that explain each piece of functionality in detail. There’s an installation guide as well as detailed step-by-step manuals on how to use each of five predetermined providers and how to implement a custom provider.

Maintenance and Support

Since AuthorizeMe is a brand new library, it’s well maintained and supported. Unlike SimpleAuth, which hasn’t been supported for two years already, our library stays up to date with the latest updates. Therefore, if a provider makes changes or modifications to its API, our team will rapidly fix the code to prevent issues like app crashes.

How to Install the FacebookProvider

In order to show you how easy it is to work with AuthorizeMe, we’ll explain how to install the FacebookProvider.

Step 2. Create and configure a test application

Click the Settings button in the left corner. A Basic Settings mode will be selected by default. In basic settings you’ll find App ID parameters, which are required for the FacebookProvider.

Click the Add Platform button and choose iOS.

Fill in the Bundle ID field with the data from the Bundle Identifier field in your Xcode project.

Click Save Changes.

Toggle the Native or Desktop App? button to the active mode in the Advanced Settings tab.

Step 3. Create and Configure Facebook Login Product

Add a new product by tapping the Add Product button on the left.

Find the Facebook Login product and click the Get Started button.

Fill in the Valid OAuth redirect URIs field on the Facebook Login Settings tab.Notice that this is the second parameter required for a FacebookProvider.

Step 4. Create and Configure a Plist File

Create a Facebook.plist file and add the following code to the file:

Step 5. Use the Framework

Use the Authorize manager, which authorizes a user with FacebookSystemProvider if possible. In other case, the manager authorizes a user with FacebookWebProvider.

In order to distinguish between use of these two providers, use FacebookSystemProvider and FacebookWebProvider separately.

AuthorizeMe and the iOS 11 Update

The AuthorizeMe library is built on provider classes: there’s a basic provider class that inherits provider classes of social networks and services. For example, the FacebookProvider class inherits two classes: FacebookSystemProvider and FacebookWebProvider.

This first provider retrieves data from system accounts if a user is signed in via a device’s settings. The second provider uses WebView for sign-in: a user fills in data in WebView to authorize and gets a token.

In addition to providers, AuthorizeMe has an Authorize class wrapper. When users try to sign in to their Facebook accounts, Authorize attempts to authorize with the help of a system provider, and if that attempt fails, with the help of a web provider. Not all social networks and services have a system provider, since system settings in iOS provide the ability to authorize only with four social networks.

In addition, Apple has completely eliminated system authorization in iOS 11.Frankly speaking, this was an unexpected update, since we were in the middle of developing AuthorizeMe; however, we took this into consideration and fixed the problem.

To handle the issue of system authorization, you can follow one of two methods. With iOS 11 and higher, you’re only able to authorize via a browser. If you use the AuthorizeMe library on devices running iOS 11 or higher, you’ll get a notification that authorization with system accounts has been deprecated.

On devices with iOS 10, you can try to authorize with a system account, and if that fails, then attempt authorization via a browser.

We’d be glad if you used the AuthorizeMe library in your iOS app and shared your feedback with us! Also, if you’d like to contribute to the AuthorizeMe project or suggest further improvements, feel free to visit our GitHub and start a discussion on Twitter!

Hi Bruce! Actually, you can use any URL - it's all up to you.
On GitHub, we have an example with a screenshot in Step 3 that includes RubyGarage's website URL: https://rubygarage.org/. So, if you develop an authorizaton feature for a mobile app that has a website, you can use your website URL.
So, one can use any URL and the library will handle it. The only thing that matters is the same URL in a Facebook admin panel and a library configuration file. Remember about that :)

"Fill in the Valid OAuth redirect URIs field on the Facebook Login Settings tab.Notice that this is the second parameter required for a FacebookProvider." Fill in with what exactly? How do I get a Valid OAuth redirect URI?