SwiftySocial is a tiny library for adding support for social login buttons to your app (like Login with Google
etc). If you are tired of the data-snooping and bloatware SDKs provided by Firebase and Facebook etc, this library is for you. It does not collect any analytical data and does not track you in any way.
Since OAuth is an open standard, we can provide support for these OAuth providers without using their SDKs.
Usage • Providers • Sample App • Installation • Other Projects • License
Add the file SwiftySocialInfo.plist
to your app and fill in the credentials for the login provider you want to support. For example, if you want to add support for Login with Google
, provide the following values. Do not change the key names.
<!-- ******* Google ******* -->
<key>GOOGLE_CLIENT_ID</key>
<string>your client id</string>
<key>GOOGLE_CALLBACK_SCHEME</key>
<string>your callback scheme</string>
<key>GOOGLE_CALLBACK_HOST</key>
<string>your callback host</string>
After importing the library, add the following code snippet in your button click handler. The returned user
object will contain the access_token
and other information. Please see SwiftySocialUser.swift
for details.
import SwiftySocial
SwiftySocial(for: .google).login { result in
switch result {
case .success(let user):
print(user.accessToken)
case .failure(let error):
print(error.description)
}
}
The final response object SwiftySocialUser
has the following fields:
public struct SwiftySocialUser {
public let userId: String
public let userName: String
public let email: String?
public let accessToken: String
public let refreshToken: String?
}
The SDK supports the following providers. More providers will be added over time.
- Github
- Dropbox
- Microsoft
- More to come...
The accompanying demo app SwiftySocialDemo
implements a few of these providers.
Some of these libraries have been around for a long time and have been battle-tested.
- Heimdallr.swift - Easy to use OAuth 2 library for iOS, written in Swift.
- InstagramSimpleOAuth - A quick and simple way to authenticate an Instagram user in your iPhone or iPad app.
- LinkedInSignIn - Simple view controller to login and retrieve access token from LinkedIn.
- OAuthSwift - Swift based OAuth library for iOS.
- OAuth2 - OAuth2 framework for macOS and iOS, written in Swift.
- ReCaptcha - (In)visible ReCaptcha for iOS.
- SwiftyOAuth - A simple OAuth library for iOS with a built-in set of providers.
Copyright (c) 2023 Manish Kumar (manish.bansal@gmail.com)
The detailed license text can be seen here.