Skip to content

Commit 34d6a9f

Browse files
committed
feat: add Spotify login to 3rd party login providers
1 parent 4ccb8a6 commit 34d6a9f

File tree

4 files changed

+369
-0
lines changed

4 files changed

+369
-0
lines changed

ParseSwift.xcodeproj/project.pbxproj

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,18 @@
760760
7C4C0947285EA60E00F202C6 /* ParseInstagramAsyncTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C4C0946285EA60E00F202C6 /* ParseInstagramAsyncTests.swift */; };
761761
7C4C0948285EA60E00F202C6 /* ParseInstagramAsyncTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C4C0946285EA60E00F202C6 /* ParseInstagramAsyncTests.swift */; };
762762
7C4C0949285EA60E00F202C6 /* ParseInstagramAsyncTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C4C0946285EA60E00F202C6 /* ParseInstagramAsyncTests.swift */; };
763+
7C55F9E72860CD6B002A352D /* ParseSpotify.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C55F9E62860CD6B002A352D /* ParseSpotify.swift */; };
764+
7C55F9E82860CD6B002A352D /* ParseSpotify.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C55F9E62860CD6B002A352D /* ParseSpotify.swift */; };
765+
7C55F9E92860CD6B002A352D /* ParseSpotify.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C55F9E62860CD6B002A352D /* ParseSpotify.swift */; };
766+
7C55F9EA2860CD6B002A352D /* ParseSpotify.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C55F9E62860CD6B002A352D /* ParseSpotify.swift */; };
767+
7C55F9EC2860CEA6002A352D /* ParseSpotify+async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C55F9EB2860CEA6002A352D /* ParseSpotify+async.swift */; };
768+
7C55F9ED2860CEA6002A352D /* ParseSpotify+async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C55F9EB2860CEA6002A352D /* ParseSpotify+async.swift */; };
769+
7C55F9EE2860CEA6002A352D /* ParseSpotify+async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C55F9EB2860CEA6002A352D /* ParseSpotify+async.swift */; };
770+
7C55F9EF2860CEA6002A352D /* ParseSpotify+async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C55F9EB2860CEA6002A352D /* ParseSpotify+async.swift */; };
771+
7C55F9F12860CEEF002A352D /* ParseSpotify+combine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C55F9F02860CEEF002A352D /* ParseSpotify+combine.swift */; };
772+
7C55F9F22860CEEF002A352D /* ParseSpotify+combine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C55F9F02860CEEF002A352D /* ParseSpotify+combine.swift */; };
773+
7C55F9F32860CEEF002A352D /* ParseSpotify+combine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C55F9F02860CEEF002A352D /* ParseSpotify+combine.swift */; };
774+
7C55F9F42860CEEF002A352D /* ParseSpotify+combine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C55F9F02860CEEF002A352D /* ParseSpotify+combine.swift */; };
763775
7FFF552E2217E72A007C3B4E /* AnyEncodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FFF552B2217E729007C3B4E /* AnyEncodableTests.swift */; };
764776
7FFF552F2217E72A007C3B4E /* AnyCodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FFF552C2217E729007C3B4E /* AnyCodableTests.swift */; };
765777
7FFF55302217E72A007C3B4E /* AnyDecodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FFF552D2217E729007C3B4E /* AnyDecodableTests.swift */; };
@@ -1311,6 +1323,9 @@
13111323
7C4C093E285EA3A000F202C6 /* ParseInstagramTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParseInstagramTests.swift; sourceTree = "<group>"; };
13121324
7C4C0942285EA56E00F202C6 /* ParseInstagramCombineTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParseInstagramCombineTests.swift; sourceTree = "<group>"; };
13131325
7C4C0946285EA60E00F202C6 /* ParseInstagramAsyncTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParseInstagramAsyncTests.swift; sourceTree = "<group>"; };
1326+
7C55F9E62860CD6B002A352D /* ParseSpotify.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParseSpotify.swift; sourceTree = "<group>"; };
1327+
7C55F9EB2860CEA6002A352D /* ParseSpotify+async.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ParseSpotify+async.swift"; sourceTree = "<group>"; };
1328+
7C55F9F02860CEEF002A352D /* ParseSpotify+combine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ParseSpotify+combine.swift"; sourceTree = "<group>"; };
13141329
7FFF552B2217E729007C3B4E /* AnyEncodableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnyEncodableTests.swift; sourceTree = "<group>"; };
13151330
7FFF552C2217E729007C3B4E /* AnyCodableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnyCodableTests.swift; sourceTree = "<group>"; };
13161331
7FFF552D2217E729007C3B4E /* AnyDecodableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnyDecodableTests.swift; sourceTree = "<group>"; };
@@ -1907,6 +1922,7 @@
19071922
70F03A212780B8D000E5AFB4 /* ParseGoogle */,
19081923
703B096226BF486C005A112F /* ParseLDAP */,
19091924
70F03A322780C7EB00E5AFB4 /* ParseLinkedIn */,
1925+
7C55F9E52860CD48002A352D /* ParseSpotify */,
19101926
703B096326BF487E005A112F /* ParseTwitter */,
19111927
);
19121928
path = "3rd Party";
@@ -1978,6 +1994,16 @@
19781994
path = ParseInstagram;
19791995
sourceTree = "<group>";
19801996
};
1997+
7C55F9E52860CD48002A352D /* ParseSpotify */ = {
1998+
isa = PBXGroup;
1999+
children = (
2000+
7C55F9E62860CD6B002A352D /* ParseSpotify.swift */,
2001+
7C55F9EB2860CEA6002A352D /* ParseSpotify+async.swift */,
2002+
7C55F9F02860CEEF002A352D /* ParseSpotify+combine.swift */,
2003+
);
2004+
path = ParseSpotify;
2005+
sourceTree = "<group>";
2006+
};
19812007
7FFF552A2217E729007C3B4E /* AnyCodableTests */ = {
19822008
isa = PBXGroup;
19832009
children = (
@@ -2578,6 +2604,7 @@
25782604
buildActionMask = 2147483647;
25792605
files = (
25802606
F97B463724D9C74400F4A88B /* Responses.swift in Sources */,
2607+
7C55F9EC2860CEA6002A352D /* ParseSpotify+async.swift in Sources */,
25812608
916786E2259B7DDA00BB5B4E /* ParseCloud.swift in Sources */,
25822609
70CE0AC6285FD5A800DAEA86 /* ParseHookFunctionable+combine.swift in Sources */,
25832610
91F346B9269B766C005727B6 /* CloudViewModel.swift in Sources */,
@@ -2652,6 +2679,7 @@
26522679
70CE0A9E28592A2B00DAEA86 /* ParseCloudUser.swift in Sources */,
26532680
705A9A2F25991C1400B3547F /* Fileable.swift in Sources */,
26542681
89899D342603CF36002E2043 /* ParseTwitter.swift in Sources */,
2682+
7C55F9F12860CEEF002A352D /* ParseSpotify+combine.swift in Sources */,
26552683
70B4E0BC2762F1D5004C9757 /* QueryConstraint.swift in Sources */,
26562684
70C167B427304F09009F4E30 /* Pointer+async.swift in Sources */,
26572685
705025AE28456106008D6624 /* ParsePushStatusable.swift in Sources */,
@@ -2663,6 +2691,7 @@
26632691
700396F825A394AE0052CB31 /* ParseLiveQueryDelegate.swift in Sources */,
26642692
F97B465A24D9C78C00F4A88B /* Increment.swift in Sources */,
26652693
7045769326BD8F8100F86F71 /* ParseInstallation+async.swift in Sources */,
2694+
7C55F9E72860CD6B002A352D /* ParseSpotify.swift in Sources */,
26662695
7003960925A184EF0052CB31 /* ParseLiveQuery.swift in Sources */,
26672696
7044C17525C4ECFF0011F6E7 /* ParseCloud+combine.swift in Sources */,
26682697
705025B32845C302008D6624 /* ParsePushStatus.swift in Sources */,
@@ -2874,6 +2903,7 @@
28742903
buildActionMask = 2147483647;
28752904
files = (
28762905
F97B463824D9C74400F4A88B /* Responses.swift in Sources */,
2906+
7C55F9ED2860CEA6002A352D /* ParseSpotify+async.swift in Sources */,
28772907
916786E3259B7DDA00BB5B4E /* ParseCloud.swift in Sources */,
28782908
70CE0AC7285FD5A800DAEA86 /* ParseHookFunctionable+combine.swift in Sources */,
28792909
91F346BA269B766D005727B6 /* CloudViewModel.swift in Sources */,
@@ -2948,6 +2978,7 @@
29482978
70CE0A9F28592A2B00DAEA86 /* ParseCloudUser.swift in Sources */,
29492979
89899D332603CF36002E2043 /* ParseTwitter.swift in Sources */,
29502980
70B4E0BD2762F1D5004C9757 /* QueryConstraint.swift in Sources */,
2981+
7C55F9F22860CEEF002A352D /* ParseSpotify+combine.swift in Sources */,
29512982
70C167B527304F09009F4E30 /* Pointer+async.swift in Sources */,
29522983
F97B464B24D9C78B00F4A88B /* Delete.swift in Sources */,
29532984
705025AF28456106008D6624 /* ParsePushStatusable.swift in Sources */,
@@ -2959,6 +2990,7 @@
29592990
F97B465B24D9C78C00F4A88B /* Increment.swift in Sources */,
29602991
7045769426BD8F8100F86F71 /* ParseInstallation+async.swift in Sources */,
29612992
7003960A25A184EF0052CB31 /* ParseLiveQuery.swift in Sources */,
2993+
7C55F9E82860CD6B002A352D /* ParseSpotify.swift in Sources */,
29622994
7044C17625C4ECFF0011F6E7 /* ParseCloud+combine.swift in Sources */,
29632995
F97B45E324D9C6F200F4A88B /* AnyEncodable.swift in Sources */,
29642996
705025B42845C302008D6624 /* ParsePushStatus.swift in Sources */,
@@ -3295,6 +3327,7 @@
32953327
buildActionMask = 2147483647;
32963328
files = (
32973329
F97B45D524D9C6F200F4A88B /* AnyDecodable.swift in Sources */,
3330+
7C55F9EF2860CEA6002A352D /* ParseSpotify+async.swift in Sources */,
32983331
916786E5259B7DDA00BB5B4E /* ParseCloud.swift in Sources */,
32993332
70CE0AC9285FD5A800DAEA86 /* ParseHookFunctionable+combine.swift in Sources */,
33003333
91F346BC269B766D005727B6 /* CloudViewModel.swift in Sources */,
@@ -3369,6 +3402,7 @@
33693402
70CE0AA128592A2B00DAEA86 /* ParseCloudUser.swift in Sources */,
33703403
705A9A3225991C1400B3547F /* Fileable.swift in Sources */,
33713404
70B4E0BF2762F1D5004C9757 /* QueryConstraint.swift in Sources */,
3405+
7C55F9F42860CEEF002A352D /* ParseSpotify+combine.swift in Sources */,
33723406
89899D282603CF35002E2043 /* ParseTwitter.swift in Sources */,
33733407
70C167B727304F09009F4E30 /* Pointer+async.swift in Sources */,
33743408
705025B128456106008D6624 /* ParsePushStatusable.swift in Sources */,
@@ -3380,6 +3414,7 @@
33803414
700396FB25A394AE0052CB31 /* ParseLiveQueryDelegate.swift in Sources */,
33813415
F97B463A24D9C74400F4A88B /* Responses.swift in Sources */,
33823416
7045769626BD8F8100F86F71 /* ParseInstallation+async.swift in Sources */,
3417+
7C55F9EA2860CD6B002A352D /* ParseSpotify.swift in Sources */,
33833418
7003960C25A184EF0052CB31 /* ParseLiveQuery.swift in Sources */,
33843419
7044C17825C4ECFF0011F6E7 /* ParseCloud+combine.swift in Sources */,
33853420
705025B62845C302008D6624 /* ParsePushStatus.swift in Sources */,
@@ -3475,6 +3510,7 @@
34753510
buildActionMask = 2147483647;
34763511
files = (
34773512
F97B45D424D9C6F200F4A88B /* AnyDecodable.swift in Sources */,
3513+
7C55F9EE2860CEA6002A352D /* ParseSpotify+async.swift in Sources */,
34783514
916786E4259B7DDA00BB5B4E /* ParseCloud.swift in Sources */,
34793515
70CE0AC8285FD5A800DAEA86 /* ParseHookFunctionable+combine.swift in Sources */,
34803516
91F346BB269B766D005727B6 /* CloudViewModel.swift in Sources */,
@@ -3549,6 +3585,7 @@
35493585
70CE0AA028592A2B00DAEA86 /* ParseCloudUser.swift in Sources */,
35503586
705A9A3125991C1400B3547F /* Fileable.swift in Sources */,
35513587
70B4E0BE2762F1D5004C9757 /* QueryConstraint.swift in Sources */,
3588+
7C55F9F32860CEEF002A352D /* ParseSpotify+combine.swift in Sources */,
35523589
89899D322603CF35002E2043 /* ParseTwitter.swift in Sources */,
35533590
70C167B627304F09009F4E30 /* Pointer+async.swift in Sources */,
35543591
705025B028456106008D6624 /* ParsePushStatusable.swift in Sources */,
@@ -3560,6 +3597,7 @@
35603597
700396FA25A394AE0052CB31 /* ParseLiveQueryDelegate.swift in Sources */,
35613598
F97B463924D9C74400F4A88B /* Responses.swift in Sources */,
35623599
7045769526BD8F8100F86F71 /* ParseInstallation+async.swift in Sources */,
3600+
7C55F9E92860CD6B002A352D /* ParseSpotify.swift in Sources */,
35633601
7003960B25A184EF0052CB31 /* ParseLiveQuery.swift in Sources */,
35643602
7044C17725C4ECFF0011F6E7 /* ParseCloud+combine.swift in Sources */,
35653603
705025B52845C302008D6624 /* ParsePushStatus.swift in Sources */,
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
//
2+
// ParseSpotify+async.swift
3+
// ParseSwift
4+
//
5+
// Created by Ulaş Sancak on 06/20/22.
6+
// Copyright © 2022 Parse Community. All rights reserved.
7+
//
8+
9+
#if compiler(>=5.5.2) && canImport(_Concurrency)
10+
import Foundation
11+
12+
public extension ParseSpotify {
13+
// MARK: Async/Await
14+
15+
/**
16+
Login a `ParseUser` *asynchronously* using Spotify authentication.
17+
- parameter id: The **Spotify profile id** from **Spotify**.
18+
- parameter accessToken: Required **access_token** from **Spotify**.
19+
- parameter options: A set of header options sent to the server. Defaults to an empty set.
20+
- returns: An instance of the logged in `ParseUser`.
21+
- throws: An error of type `ParseError`.
22+
*/
23+
func login(id: String,
24+
accessToken: String,
25+
options: API.Options = []) async throws -> AuthenticatedUser {
26+
try await withCheckedThrowingContinuation { continuation in
27+
self.login(id: id,
28+
accessToken: accessToken,
29+
options: options,
30+
completion: continuation.resume)
31+
}
32+
}
33+
34+
/**
35+
Login a `ParseUser` *asynchronously* using Spotify authentication.
36+
- parameter authData: Dictionary containing key/values.
37+
- returns: An instance of the logged in `ParseUser`.
38+
- throws: An error of type `ParseError`.
39+
*/
40+
func login(authData: [String: String],
41+
options: API.Options = []) async throws -> AuthenticatedUser {
42+
try await withCheckedThrowingContinuation { continuation in
43+
self.login(authData: authData,
44+
options: options,
45+
completion: continuation.resume)
46+
}
47+
}
48+
}
49+
50+
public extension ParseSpotify {
51+
52+
/**
53+
Link the *current* `ParseUser` *asynchronously* using Spotify authentication.
54+
- parameter id: The **Spotify profile id** from **Spotify**.
55+
- parameter accessToken: Required **access_token** from **Spotify**.
56+
- parameter options: A set of header options sent to the server. Defaults to an empty set.
57+
- returns: An instance of the logged in `ParseUser`.
58+
- throws: An error of type `ParseError`.
59+
*/
60+
func link(id: String,
61+
accessToken: String,
62+
options: API.Options = []) async throws -> AuthenticatedUser {
63+
try await withCheckedThrowingContinuation { continuation in
64+
self.link(id: id,
65+
accessToken: accessToken,
66+
options: options,
67+
completion: continuation.resume)
68+
}
69+
}
70+
71+
/**
72+
Link the *current* `ParseUser` *asynchronously* using Spotify authentication.
73+
- parameter authData: Dictionary containing key/values.
74+
- parameter options: A set of header options sent to the server. Defaults to an empty set.
75+
- returns: An instance of the logged in `ParseUser`.
76+
- throws: An error of type `ParseError`.
77+
*/
78+
func link(authData: [String: String],
79+
options: API.Options = []) async throws -> AuthenticatedUser {
80+
try await withCheckedThrowingContinuation { continuation in
81+
self.link(authData: authData,
82+
options: options,
83+
completion: continuation.resume)
84+
}
85+
}
86+
}
87+
#endif
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//
2+
// ParseSpotify+combine.swift
3+
// ParseSwift
4+
//
5+
// Created by Ulaş Sancak on 06/20/22.
6+
// Copyright © 2022 Parse Community. All rights reserved.
7+
//
8+
9+
#if canImport(Combine)
10+
import Foundation
11+
import Combine
12+
13+
public extension ParseSpotify {
14+
// MARK: Combine
15+
/**
16+
Login a `ParseUser` *asynchronously* using Spotify authentication. Publishes when complete.
17+
- parameter id: The **Spotify profile id** from **Spotify**.
18+
- parameter accessToken: Required **access_token** from **Spotify**.
19+
- parameter options: A set of header options sent to the server. Defaults to an empty set.
20+
- returns: A publisher that eventually produces a single value and then finishes or fails.
21+
*/
22+
func loginPublisher(id: String,
23+
accessToken: String,
24+
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
25+
Future { promise in
26+
self.login(id: id,
27+
accessToken: accessToken,
28+
options: options,
29+
completion: promise)
30+
}
31+
}
32+
33+
/**
34+
Login a `ParseUser` *asynchronously* using Spotify authentication. Publishes when complete.
35+
- parameter authData: Dictionary containing key/values.
36+
- returns: A publisher that eventually produces a single value and then finishes or fails.
37+
*/
38+
func loginPublisher(authData: [String: String],
39+
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
40+
Future { promise in
41+
self.login(authData: authData,
42+
options: options,
43+
completion: promise)
44+
}
45+
}
46+
}
47+
48+
public extension ParseSpotify {
49+
/**
50+
Link the *current* `ParseUser` *asynchronously* using Spotify authentication.
51+
Publishes when complete.
52+
- parameter id: The **Spotify profile id** from **Spotify**.
53+
- parameter accessToken: Required **access_token** from **Spotify**.
54+
- parameter options: A set of header options sent to the server. Defaults to an empty set.
55+
- returns: A publisher that eventually produces a single value and then finishes or fails.
56+
*/
57+
func linkPublisher(id: String,
58+
accessToken: String,
59+
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
60+
Future { promise in
61+
self.link(id: id,
62+
accessToken: accessToken,
63+
options: options,
64+
completion: promise)
65+
}
66+
}
67+
68+
/**
69+
Link the *current* `ParseUser` *asynchronously* using Spotify authentication.
70+
Publishes when complete.
71+
- parameter authData: Dictionary containing key/values.
72+
- returns: A publisher that eventually produces a single value and then finishes or fails.
73+
*/
74+
func linkPublisher(authData: [String: String],
75+
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
76+
Future { promise in
77+
self.link(authData: authData,
78+
options: options,
79+
completion: promise)
80+
}
81+
}
82+
}
83+
84+
#endif

0 commit comments

Comments
 (0)