Skip to content

Commit 50f7ce9

Browse files
authored
Merge pull request #1 from spotify/hagmas-patch-1
Add files via upload
2 parents 8a5a51f + 4028aff commit 50f7ce9

40 files changed

Lines changed: 7338 additions & 1 deletion

README.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,44 @@
1-
# ios-auth
1+
# SpotifyLogin
2+
3+
## Overview
4+
`SpotifyLogin` is a lightweight framework that enables your application to obtain the authentication code from the Spotify app. Please note that this framework is currently under development and only supports a subset of the [ios-sdk](https://github.com/spotify/ios-sdk)'s functionalities. If you wish to use all features related to authentication, please utilize [ios-sdk](https://github.com/spotify/ios-sdk).
5+
6+
## Minimum Requirement
7+
iOS 11
8+
9+
## Usage
10+
### Prepare Your Environment
11+
- Install the latest version of Spotify from the App Store onto the device you will be using for development. Run the Spotify app and login or sign up.
12+
- [Register Your Application](https://developer.spotify.com/documentation/web-api/concepts/apps#register-your-app). You will need to register your application at [My Applications](https://developer.spotify.com/dashboard) and obtain a client ID. When you register your app you will also need to allowlist a redirect URI that the Spotify app will use to callback to your app after authorization.
13+
14+
### Installation
15+
- Add `SpotifyLogin.xcframework` to your project by dragging and dropping it in <b>Framworks, Libraries, and Embedded Content</b>
16+
- In your info.plist add the following changes:
17+
- Add your redirect URI you registered at My Applications. You will need to add your redirect URI under "URL types" and "URL Schemes". Be sure to set a unique "URL identifier" as well. More info on URL Schemes
18+
- Declare the Spotify’s URL scheme `spotify` by adding the `LSApplicationQueriesSchemes` key.
19+
20+
### Get authentication code
21+
1. Initialise `Configuration` with your client ID and redirect URI.
22+
```swift
23+
import SpotifyLogin
24+
25+
let configuration = Configuration(clientID: "your_client_id", redirectURLString: "your_redirect_uri")
26+
```
27+
2. Initialise `SessionManager` with your configuration and set an object that conforms `SessionManagerDelegate` to the `delegate` of the instance.
28+
```swift
29+
let sessionManager = SessionManager(configuration: configuration)
30+
sessionManager.delegate = <#delegate object#>
31+
```
32+
3. Implement `application(_:open:options:)` method to your `UIApplicationDelegate` and call sessionManager's `application(_:open:options:)` there.
33+
```swift
34+
class AppDelegate: NSObject, UIApplicationDelegate {
35+
func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
36+
return sessionManager.application(application, open: url, options: options)
37+
}
38+
}
39+
```
40+
4. Start the authrization process with the scopes you need.
41+
```swift
42+
sessionManager.startAuthorizationCodeProcess(with: [.playlistModifyPublic, .playlistModifyPrivate])
43+
```
44+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>AvailableLibraries</key>
6+
<array>
7+
<dict>
8+
<key>LibraryIdentifier</key>
9+
<string>ios-arm64</string>
10+
<key>LibraryPath</key>
11+
<string>SpotifyLogin.framework</string>
12+
<key>SupportedArchitectures</key>
13+
<array>
14+
<string>arm64</string>
15+
</array>
16+
<key>SupportedPlatform</key>
17+
<string>ios</string>
18+
</dict>
19+
<dict>
20+
<key>LibraryIdentifier</key>
21+
<string>ios-arm64_x86_64-simulator</string>
22+
<key>LibraryPath</key>
23+
<string>SpotifyLogin.framework</string>
24+
<key>SupportedArchitectures</key>
25+
<array>
26+
<string>arm64</string>
27+
<string>x86_64</string>
28+
</array>
29+
<key>SupportedPlatform</key>
30+
<string>ios</string>
31+
<key>SupportedPlatformVariant</key>
32+
<string>simulator</string>
33+
</dict>
34+
</array>
35+
<key>CFBundlePackageType</key>
36+
<string>XFWK</string>
37+
<key>XCFrameworkFormatVersion</key>
38+
<string>1.0</string>
39+
</dict>
40+
</plist>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#import <Foundation/Foundation.h>
2+
3+
/// `SPTScope` represents the OAuth scopes that declare how your app wants to access a user's account.
4+
/// See https://developer.spotify.com/web-api/using-scopes/ for more information.
5+
typedef NS_OPTIONS(NSUInteger, SPTScope) {
6+
// Read access to user's private playlists.
7+
SPTScopePlaylistReadPrivate = 1 << 0,
8+
9+
// Include collaborative playlists when requesting a user's playlists.
10+
SPTScopePlaylistReadCollaborative = 1 << 1,
11+
12+
// Write access to a user's public playlists.
13+
SPTScopePlaylistModifyPublic = 1 << 2,
14+
15+
// Write access to a user's private playlists.
16+
SPTScopePlaylistModifyPrivate = 1 << 3,
17+
18+
// Read access to the list of artists and other users that the user follows.
19+
SPTScopeUserFollowRead = 1 << 4,
20+
21+
// Write/delete access to the list of artists and other users that the user follows.
22+
SPTScopeUserFollowModify = 1 << 5,
23+
24+
// Read access to a user's "Your Music" library.
25+
SPTScopeUserLibraryRead = 1 << 6,
26+
27+
// Write/delete access to a user's "Your Music" library.
28+
SPTScopeUserLibraryModify = 1 << 7,
29+
30+
// Read access to the user's birthdate.
31+
SPTScopeUserReadBirthDate = 1 << 8,
32+
33+
// Read access to user’s email address.
34+
SPTScopeUserReadEmail = 1 << 9,
35+
36+
// Read access to user’s subscription details (type of user account).
37+
SPTScopeUserReadPrivate = 1 << 10,
38+
39+
// Read access to a user's top artists and tracks.
40+
SPTScopeUserTopRead = 1 << 11,
41+
42+
// Upload user generated content images.
43+
SPTScopeUgcImageUpload = 1 << 12,
44+
45+
// Control playback of a Spotify track.
46+
SPTScopeStreaming = 1 << 13,
47+
48+
// Read access to a user’s player state.
49+
SPTScopeUserReadPlaybackState = 1 << 14,
50+
51+
// Write access to a user’s playback state.
52+
SPTScopeUserModifyPlaybackState = 1 << 15,
53+
54+
// Read access to a user’s currently playing track.
55+
SPTScopeUserReadCurrentlyPlaying = 1 << 16,
56+
57+
// Read access to a user’s recently played tracks.
58+
SPTScopeUserReadRecentlyPlayed = 1 << 17,
59+
60+
// Indicate that the application intends to use OIDC to verify the user's identity
61+
SPTScopeOpenid = 1 << 18
62+
} NS_SWIFT_NAME(Scope);

0 commit comments

Comments
 (0)