Swiftpack.co - manishkumar03/SwiftySocial as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by manishkumar03.
manishkumar03/SwiftySocial v1.0.1
An OAuth library for iOS written in Swift. Does not use any of the first-party SDKs such as those provided by Firebase etc.
⭐️ 1
🕓 1 year ago
iOS
.package(url: "https://github.com/manishkumar03/SwiftySocial.git", from: "v1.0.1")

SwiftySocial


An OAuth library for iOS

Overview

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.

UsageProvidersSample AppInstallationOther ProjectsLicense

Usage

Step 1: Add login provider credentials

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>
Step 2: Ask for authorization

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?
}

Providers

The SDK supports the following providers. More providers will be added over time.

  • Google
  • Github
  • Reddit
  • Dropbox
  • LinkedIn
  • Microsoft
  • More to come...

Sample App

The accompanying demo app SwiftySocialDemo implements a few of these providers.


Other Projects

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.

License

Copyright (c) 2023 Manish Kumar ([email protected])

The detailed license text can be seen here.

GitHub

link
Stars: 1
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

SwiftySocial v1.0.1
1 year ago

Removed Facebook as an OAuth login provider. They now require the users of their API to have a verified business.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics