Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 7ff6823

Browse files
committed
Adding apple specific parameters to social service connect.
1 parent 7022bdf commit 7ff6823

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

WordPressKit/AccountServiceRemoteREST+SocialService.swift

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,35 @@ extension AccountServiceRemoteREST {
1313
/// - Parameters:
1414
/// - service The name of the social service.
1515
/// - token The OpenID Connect (JWT) ID token identifying the user on the social service.
16+
/// - appleEmail The email address associated with an Apple ID. Optional.
17+
/// - appleFullName The full name associated with an Apple ID. Optional.
1618
/// - oAuthClientID The WPCOM REST API client ID.
1719
/// - oAuthClientSecret The WPCOM REST API client secret.
1820
/// - success The block that will be executed on success.
1921
/// - failure The block that will be executed on failure.
20-
public func connectToSocialService(_ service: SocialServiceName, serviceIDToken token: String, oAuthClientID: String, oAuthClientSecret: String, success:@escaping (() -> Void), failure:@escaping ((NSError) -> Void)) {
22+
public func connectToSocialService(_ service: SocialServiceName,
23+
serviceIDToken token: String,
24+
appleEmail: String? = nil,
25+
appleFullName: String? = nil,
26+
oAuthClientID: String,
27+
oAuthClientSecret: String,
28+
success:@escaping (() -> Void),
29+
failure:@escaping ((NSError) -> Void)) {
2130
let path = self.path(forEndpoint: "me/social-login/connect", withVersion: ._1_1)
2231

23-
let params = [
32+
var params = [
2433
"client_id": oAuthClientID,
2534
"client_secret": oAuthClientSecret,
2635
"service": service.rawValue,
2736
"id_token": token,
2837
] as [String: AnyObject]
38+
39+
// Append Apple specific parameters
40+
if service == .apple {
41+
params["user_email"] = appleEmail as AnyObject
42+
params["user_name"] = appleFullName as AnyObject
43+
}
44+
2945
wordPressComRestApi.POST(path, parameters: params, success: { (responseObject, httpResponse) in
3046
success()
3147
}, failure: { (error, httpResponse) in

0 commit comments

Comments
 (0)