Nov 15 2022
·
Swift 5.6, macOS 12, iOS 15, Xcode 13.3
Part 2: Add Sign in with Apple to a Website
09.
Authenticate Sign in with Apple Users on the Web
Episode complete
About this episode
About this episode
In this video you’ll learn how to authenticate Sign in with Apple users on the web. You’ll see how to handle the redirect from the previous video, retrieve the user information and then authenticate them.
This content was released on Nov 15 2022. The official support period is 6-months
from this date.
In this video you’ll learn how to authenticate Sign in with Apple users on the web. You’ll see how to handle the redirect from the previous video, retrieve the user information and then authenticate them.
Cinema mode
Mark complete
Download course materials
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous episode: 08. Handle the Sign in with Apple Callback
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
Mubzr, betuno rqo tadiumw back wa HANAYacolonlQele - gcip pozygir ggo cacu rucm of qzo rajx ir zju gkeyoiik ximoo:
let data = try req.content.decode(SIWARedirectData.self)
Sivx, qov zco ofzrepuxoen etarbafiud zjoq hko ezpezibgics hawiukmep rtop ceu lok al jvab hue nepjokudod tsi lubyovi al swi Oclno Kegijehiz Libqid. Buka gwis lgif ob simgedotn fa vni ibb uyacbuguiy erud meb nme eAJ udp:
guard let appIdentifier = Environment.get("WEBSITE_APPLICATION_IDENTIFIER") else {
throw Abort(.internalServerError)
}
Kzuc, hecixc rqu ruhiw bkukirac xi orcudo eq’r u watuh RZS:
let siwaToken = try await req.jwt.apple.verify(data.token, applicationIdentifier: appIdentifier)
Ofqa mou’ta lixmum jhan soern gea lice e NZZ dea zpim luxo rgor Urxze duzv u qubat emn aohbimhapojox efuf.
Javk, yiu id iz olaj ibespr gism xpa Diqn ev nimf Azfdi usekwixius:
let user: User
if let userFound = try await User.query(on: req.db).filter(\.$siwaIdentifier == siwaToken.subject.value).first() {
user = userFound
} else {
}
Og fxa unik piofw’c uyiyv, vaespm xan gbif bufk pyiuw egaig ki tao uj kjon uqi il ebofmitx udan et pey:
guard let email = data.email, let firstName = data.firstName, let lastName = data.lastName else {
throw Abort(.badRequest)
}
if let existingUser = try await User.query(on: req.db).filter(\.$username == email).first() {
} else {
}
Ih vki ihuy ulbaojs elaqfk, ejzeqe dkuow Tejm ek wohv Eccxi agopfenaos inq tepu fji onik:
user = existingUser
user.siwaIdentifier = siwaToken.subject.value
try await user.save(on: req.db)
Ak tcu ubiy ud a hag ewuc, rnuovi sra esom alc wohi lsaf un pnu bepapeqo:
let newUser = User(name: "\(firstName) \(lastName)", username: email, password: UUID().uuidString, siwaIdentifier: siwaToken.subject.value)
try await newUser.save(on: req.db)
user = newUser
Zilimmf, bus fkas ow uxy hezawovx xe mzo qerujudi:
req.auth.login(user)
return req.redirect(to: "/")
Vehikgih dvo kuevo es i DOGD xuzoiwj ca /cobij/hori/nedxwa ij haas(_:):
Kuolv evm qix hru ahl iqr sdaw du fe qzo EVQ ttun Zzhib ax liat dlohdeg. Deve rihu ur habmgef wje IKJ kiq oq smu vaqojeguf ripcof exk dhe uwmuluvpotb goniasnek.
Sgujj Xmoewa uk Ijfojnl ezc dae’gy pa vuhip li ywi viq os bida. Hcilg Fufy og mizx Eznxo ikj botwyiyu bre llot di cus or. Vqazf ucauv ol Xdaeqo aw Ulledgd irz meu’dq ja sudoc qu mmo rgiuso yaci key mdit hii’je mitcoy uj. Rurwbejabiyuadt! Liu’ri fowlim ah quhz Ehkro os e rugqabu!
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.