{"id":15038676,"url":"https://github.com/thywis/multiaccountoauth","last_synced_at":"2025-04-09T23:53:32.745Z","repository":{"id":56920966,"uuid":"95175382","full_name":"Thywis/MultiAccountOauth","owner":"Thywis","description":"Login to multiple Google OAuth2 accounts simultaneously on iOS","archived":false,"fork":false,"pushed_at":"2017-06-24T05:49:15.000Z","size":429,"stargazers_count":7,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T23:52:55.419Z","etag":null,"topics":["google","google-api","googleapi","googleoauth","ios","oauth2","swift3"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Thywis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-23T02:26:49.000Z","updated_at":"2023-09-11T20:44:02.000Z","dependencies_parsed_at":"2022-08-20T21:50:25.839Z","dependency_job_id":null,"html_url":"https://github.com/Thywis/MultiAccountOauth","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thywis%2FMultiAccountOauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thywis%2FMultiAccountOauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thywis%2FMultiAccountOauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thywis%2FMultiAccountOauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Thywis","download_url":"https://codeload.github.com/Thywis/MultiAccountOauth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131453,"owners_count":21052819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google","google-api","googleapi","googleoauth","ios","oauth2","swift3"],"created_at":"2024-09-24T20:39:38.792Z","updated_at":"2025-04-09T23:53:32.722Z","avatar_url":"https://github.com/Thywis.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MultiAccountOAuth\n\nMultiAccountOAuth allows you to login to multiple Google OAuth accounts simultaneouly. \n\n\u003cimg src=\"img/screenshot.png\" width=\"375\" height=\"667\"/\u003e\n\nWhile developing [PickedMail - The personal AI Inbox](https://itunes.apple.com/us/app/pickedmail/id1244830423?mt=8), we need to support user login to multiple Google accounts simultaneously. However, Google iOS SDK only allows user to sign in to one account at a time. As a result, we developed a framework to allow us to sign in and maintain connection status to multiple Google accounts. This framework is open sourced to help others who struggling through the same problem.\n\n## Install\n```ruby\npod 'MultiAccountOAuth'\n```\n\n## Requirements\n* Swift 3.0+\n* Xcode 8.0+\n* iOS 9.0+, OSX 10.10+\n\n## Usage\n\n### Login to an Google Account\n\n```swift\npublic func signin(controller: UIViewController, completion: ((_ success: Bool, _ user: GoogleUserInstance?, _ error: String?) -\u003e ())?)\n```\n\n### Login to multiple Google accounts\n\n```swift\npublic func signin(controller: UIViewController, completion: ((_ success: Bool, _ user: GoogleUserInstance?, _ error: String?) -\u003e ())?)\n```\n\n### Get access to all of them \n\n```swift\npublic var authenticatedUsers = [GoogleUserInstance]()\n```\n\n### Next time when the user launches the app, sign in to all the Google accounts from background.\n\n```swift\npublic func signinAllUsersSilently(completion: @escaping ()-\u003e() = {})\n```\n\n\n## Step by Step Setup Guide\n\n### 1. Google Credential\n\n* Create an iOS Applicaiton in Google API Console. Make sure you have the correct client id and URL scheme.\n\n\u003cimg src=\"img/instruction1.png\" width=\"888\" height=\"194\"/\u003e\n\n* Go to Info.plist in your iOS application, add the URL scheme to URL types.\n\n\u003cimg src=\"img/instruction2.png\" width=\"1080\" height=\"99\"/\u003e\n\n### 2. AppDelegate.swift\n\nConfigure the google client id and URL scheme. You can optionally provide a server client id if you'd like to enable backend sever access.\n\n```swift\nimport UIKit\nimport MultiAccountOAuth\n\n@UIApplicationMain\nclass AppDelegate: UIResponder, UIApplicationDelegate {\n\n    var window: UIWindow?\n\n    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -\u003e Bool {\n\n        OauthManager.sharedInstance.configure(cliendId: \"269767058620-boug6i0q16vsh7a90cf7341skc1j91sj.apps.googleusercontent.com\", scope: [\"email\"], urlScheme: \"com.googleusercontent.apps.269767058620-boug6i0q16vsh7a90cf7341skc1j91sj\", serverCliendId: nil)\n\n        return true\n    }\n\n    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -\u003e Bool {\n        if let oauthSession = OauthManager.sharedInstance.oauthSession {\n            if oauthSession.resumeAuthorizationFlow(with: url) {\n                OauthManager.sharedInstance.oauthSession = nil\n                return true\n            }\n        }\n        return false\n    }\n}\n\n```\n\n### The list of Google Scopes to choose from\n\n* https://developers.google.com/identity/protocols/googlescopes\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthywis%2Fmultiaccountoauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthywis%2Fmultiaccountoauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthywis%2Fmultiaccountoauth/lists"}