do {
guard
let credential = try result.get().credential
as? ASAuthorizationAppleIDCredential
else {
logger.error("Error signing in with Apple: No credential")
return
}
guard
let idToken = credential.identityToken
.flatMap({ String(data: $0, encoding: .utf8) })
else {
logger.error("Error signing in with Apple: No idToken")
return
}
//Convert from anonymous user, but this tries to open a URL or something instead of using the auth token?
try await client.auth.linkIdentity(provider: .apple)
// This is how we'd sign in normally if there wasn't an anonymous user we wanted to link
// try await client.auth.signInWithIdToken(
// credentials: .init(
// provider: .apple,
// idToken: idToken
// )
// )
do {
guard
let credential = try result.get().credential
as? ASAuthorizationAppleIDCredential
else {
logger.error("Error signing in with Apple: No credential")
return
}
guard
let idToken = credential.identityToken
.flatMap({ String(data: $0, encoding: .utf8) })
else {
logger.error("Error signing in with Apple: No idToken")
return
}
//Convert from anonymous user, but this tries to open a URL or something instead of using the auth token?
try await client.auth.linkIdentity(provider: .apple)
// This is how we'd sign in normally if there wasn't an anonymous user we wanted to link
// try await client.auth.signInWithIdToken(
// credentials: .init(
// provider: .apple,
// idToken: idToken
// )
// )