{"id":1863,"url":"https://github.com/spotify/SpotifyLogin","last_synced_at":"2025-08-06T13:31:52.059Z","repository":{"id":48112836,"uuid":"99349003","full_name":"spotify/SpotifyLogin","owner":"spotify","description":"Swift framework for authenticating with the Spotify API","archived":true,"fork":false,"pushed_at":"2021-03-09T18:31:24.000Z","size":150,"stargazers_count":348,"open_issues_count":12,"forks_count":40,"subscribers_count":31,"default_branch":"master","last_synced_at":"2024-11-30T22:18:23.643Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spotify.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-04T14:07:41.000Z","updated_at":"2024-08-30T12:45:11.000Z","dependencies_parsed_at":"2022-08-12T18:50:39.468Z","dependency_job_id":null,"html_url":"https://github.com/spotify/SpotifyLogin","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotify%2FSpotifyLogin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotify%2FSpotifyLogin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotify%2FSpotifyLogin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotify%2FSpotifyLogin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spotify","download_url":"https://codeload.github.com/spotify/SpotifyLogin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228905435,"owners_count":17989764,"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":[],"created_at":"2024-01-05T20:15:57.567Z","updated_at":"2024-12-09T14:30:40.790Z","avatar_url":"https://github.com/spotify.png","language":"Swift","funding_links":[],"categories":["SDK","Libs","Uncategorized","Swift","Utilities and Extensions","Authentication [🔝](#readme)"],"sub_categories":["Official","Authentication","Uncategorized","Other free courses"],"readme":"![SpotifyLogin - Swift 5 Framework for authenticating with the Spotify API ](https://user-images.githubusercontent.com/889949/28974990-b2eb0328-7938-11e7-9d19-1ff86d77324b.png)\n\n[![Build Status](https://travis-ci.org/spotify/SpotifyLogin.svg?branch=master)](https://travis-ci.org/spotify/SpotifyLogin)\n[![Version](http://img.shields.io/cocoapods/v/SpotifyLogin.svg)](http://cocoapods.org/?q=SpotifyLogin)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\n# SpotifyLogin\nSpotifyLogin is a Swift 5 Framework for authenticating with the Spotify API.\n\nUsage of this framework is bound under the [Developer Terms of Use](https://developer.spotify.com/developer-terms-of-use/).\n\n## Usage\n\n### Disclaimer\nSpotifyLogin is appropriate for prototyping and non-commercial use only.\n\n**If your app is meant for commercial production usage, SpotifyLogin can NOT be used.**\n\n### Compatibility\nSpotifyLogin requires Xcode 10.2+. It is compatible with iOS 9 or later. \n\n### Pre-requisites\nYou will need to register your app in the [Developer Portal](https://developer.spotify.com/my-applications/#!/applications).\n\nMake sure to use a unique redirect url and to supply the bundle ID from your app.\n\nAfter registering, you will receive a client ID and a client secret.\n\n### Set up SpotifyLogin\n\nSet up SpotifyLogin using any of the methods detailed below (Cocoapods / Carthage / manually).\n\n### Set up info.plist\n\nIn Xcode, go to your app's target and select the **Info** tab. At the bottom, of the screen you will find **URL Types**, expand the list and create a new one.\n\n![Set up info.plist](https://user-images.githubusercontent.com/889949/28974992-b30ea08a-7938-11e7-9de5-b00656a42256.png)\n\nAdd the app's identifer as the **Identifier** and the redirect url scheme in **URL schemes**.\n\nAdditionally, you will need to add \"spotify-action\" to the LSApplicationQueriesSchemes key:\n![LSApplicationQueriesSchemes](https://user-images.githubusercontent.com/889949/29968001-f020c4d4-8f19-11e7-8925-433d3b30f842.png)\n\n### Set up your AppDelegate\n\nAdd the following to your app delegate:\n\n```swift\nfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -\u003e Bool {\n    SpotifyLogin.shared.configure(clientID: \u003c#T##String#\u003e, clientSecret: \u003c#T##String#\u003e, redirectURL: \u003c#T##URL#\u003e)\n    return true\n}\n\nfunc application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -\u003e Bool {\n    let handled = SpotifyLogin.shared.applicationOpenURL(url) { (error) in }\n    return handled\n}\n```\n\n### Check if a user is logged in.\n\nYou can retrieve an access token and check if a user is logged in by:\n\n```swift\nSpotifyLogin.shared.getAccessToken { (accessToken, error) in\n    if error != nil {\n        // User is not logged in, show log in flow.\n    }\n}\n```\n\nThis also automatically takes care of renewing expired tokens. \n\n### Log in / Log out\n\nTo add the default log in button:\n```swift\nlet button = SpotifyLoginButton(viewController: self, scopes: [.streaming, .userLibraryRead])\nself.view.addSubview(button)\n```\n\nThe scopes define the set of permissions your app will be able to use. For more information about available scopes, see [Scopes Documentation](https://developer.spotify.com/web-api/using-scopes/)\n\nTo log out:\n\n```swift\nSpotifyLogin.shared.logout()\n```\n\n### Update UI after successful log in.\n\nThe log in flow is completed in applicationOpenURL. To respond to a successful log in, you can add your own code in the completion handler or respond to the SpotifyLoginSuccessful notification: \n\n```swift\nNotificationCenter.default.addObserver(self, selector: #selector(loginSuccessful), name: .SpotifyLoginSuccessful, object: nil)\n```\n\n### Additional features\n\nAccess the current user's username:\n```swift\nlet username = SpotifyLogin.shared.username\n```\n\nTo trigger the log in flow from a custom action:\n```swift\nSpotifyLoginPresenter.login(from: self, scopes: [.streaming, .userLibraryRead])\n```\n\n## Setting up\n\n### Setting up with [CocoaPods](http://cocoapods.org/?q=SpotifyLogin)\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\npod 'SpotifyLogin', '~\u003e 0.1'\n```\n\n### Setting up with Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.\n\nYou can install Carthage with [Homebrew](http://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate SpotifyLogin into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"spotify/SpotifyLogin\"\n```\n\n## Code of conduct\nThis project adheres to the [Open Code of Conduct][code-of-conduct]. By contributing, you are expected to honor this code.\n\n[code-of-conduct]: https://github.com/spotify/code-of-conduct/blob/master/code-of-conduct.md\n\n## Additional information\n\n[Spotify Developer Portal](https://developer.spotify.com/technologies/spotify-ios-sdk/) | [API Reference](https://spotify.github.io/ios-sdk/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspotify%2FSpotifyLogin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspotify%2FSpotifyLogin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspotify%2FSpotifyLogin/lists"}