Coder Social home page Coder Social logo

manishkumar03 / swiftysocial Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 869 KB

An OAuth library for iOS written in Swift. Does not use any of the first-party SDKs such as those provided by Firebase etc.

License: MIT License

Swift 100.00%
ios library oauth oauth2-client sdk-swift swift

swiftysocial's Introduction

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.

swiftysocial's People

Contributors

manishkumar03 avatar manishkumaracv avatar

Stargazers

 avatar

Watchers

 avatar

swiftysocial's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.