Hi everyone!
I have a couple of questions about the server setup on how to support Sign in with Apple
…
First I’m going to show you my server’s setup;
var api = new ParseServer({
auth: {
'apple': {
'id': 'user',
'token': 'the identity token for the user'
}
}
});
What do I have to put to id
and token
?
This is how I’m trying to login from my iOS app;
var authData = [String : String]()
authData["access_token"] = String(decoding: appleIDCredential.authorizationCode!, as: UTF8.self)
authData["expiration_date"] = Date().description
// -----------------------------------------
PFUser.logInWithAuthType(inBackground: "apple", authData: authData).continueWith(block: { (task) -> Any? in
if task.result != nil {
if PFUser.current() != nil {
// present home screen
}
}
return nil
})
And this is how I’m trying to sign up;
var authData = [String : String]()
let userId = appleIDCredential?.user ?? passwordCredential!.user
if let appleIDCredential = appleIDCredential {
authData["token"] = String(data: appleIDCredential.identityToken!, encoding: .utf8)
authData["id"] = userId
}
// -----------------------------------------
let userEmail = appleIDCredential?.email
let name: String
if let givenName = appleIDCredential?.fullName?.givenName, let familyName = appleIDCredential?.fullName?.familyName {
name = ("\(givenName) \(familyName)")
}
else {
name = passwordCredential!.user
}
PFUser.logInWithAuthType(inBackground: "apple", authData: authData).continueWith(block: { (task) -> Any? in
if task.result != nil {
if PFUser.current() != nil {
PFUser.current()?["username"] = name
PFUser.current()?.saveInBackground(block: nil)
}
return nil
})
}
I’ve also added this on AppDelegate
;
PFUser.register(AuthDelegate(), forAuthType: "facebook")
PFUser.register(AuthDelegate(), forAuthType: "apple")
Lastly, as far as Apple’s concerned I’ve added the Sign in with Apple
capability on Xcode.
I’ve managed to get all the authentication data I need and create the user, but I fail to login!
Any help will be much appreciated!!!