@@ -133,16 +133,22 @@ struct Auth0Authentication: Authentication {
133
133
telemetry: self . telemetry)
134
134
}
135
135
136
- func login( appleAuthorizationCode authorizationCode: String , fullName: PersonNameComponents ? , scope: String ? , audience: String ? ) -> Request < Credentials , AuthenticationError > {
137
- var parameters : [ String : String ] = [ : ]
136
+ func login( appleAuthorizationCode authorizationCode: String , fullName: PersonNameComponents ? , profile: [ String : Any ] ? , scope: String ? , audience: String ? ) -> Request < Credentials , AuthenticationError > {
137
+ var parameters : [ String : Any ] = [ : ]
138
+ var profile : [ String : Any ] = profile ?? [ : ]
139
+
138
140
if let fullName = fullName {
139
141
let name = [ " firstName " : fullName. givenName, " lastName " : fullName. familyName] . compactMapValues { $0 }
140
- if !name. isEmpty,
141
- let jsonData = try ? JSONSerialization . data ( withJSONObject: [ " name " : name] , options: [ ] ) ,
142
- let json = String ( data: jsonData, encoding: . utf8) {
143
- parameters [ " user_profile " ] = json
142
+ if !name. isEmpty {
143
+ profile [ " name " ] = name
144
144
}
145
145
}
146
+
147
+ if !profile. isEmpty, let jsonData = try ? JSONSerialization . data ( withJSONObject: profile, options: [ ] ) ,
148
+ let json = String ( data: jsonData, encoding: . utf8) {
149
+ parameters [ " user_profile " ] = json
150
+ }
151
+
146
152
return self . tokenExchange ( subjectToken: authorizationCode,
147
153
subjectTokenType: " http://auth0.com/oauth/token-type/apple-authz-code " ,
148
154
scope: scope,
@@ -412,8 +418,8 @@ private extension Auth0Authentication {
412
418
return Request ( session: session, url: url, method: " POST " , handle: authenticationObject, payload: payload, logger: self . logger, telemetry: self . telemetry)
413
419
}
414
420
415
- func tokenExchange( subjectToken: String , subjectTokenType: String , scope: String ? , audience: String ? , parameters: [ String : String ] ? ) -> Request < Credentials , AuthenticationError > {
416
- var parameters : [ String : String ] = parameters ?? [ : ]
421
+ func tokenExchange( subjectToken: String , subjectTokenType: String , scope: String ? , audience: String ? , parameters: [ String : Any ] ? ) -> Request < Credentials , AuthenticationError > {
422
+ var parameters : [ String : Any ] = parameters ?? [ : ]
417
423
parameters [ " grant_type " ] = " urn:ietf:params:oauth:grant-type:token-exchange "
418
424
parameters [ " subject_token " ] = subjectToken
419
425
parameters [ " subject_token_type " ] = subjectTokenType
0 commit comments