iOS/Swift Sign In with Apple #723

Closed
opened 2026-03-13 08:01:40 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @CodeWithShreyans on GitHub (Feb 23, 2025).

I'm building a SwiftUI app that uses Sign In with Apple and needs to authenticate with my server on each request.

The first step from what I can understand is:
Trigger Sign In with Apple on the client, send the idToken to the server and pass it to authClient.signIn.social.

But I can't figure how to give the client something (possibly a JWT) that it can send with requests to my server and I can verify it and process the request.

Originally created by @CodeWithShreyans on GitHub (Feb 23, 2025). I'm building a SwiftUI app that uses Sign In with Apple and needs to authenticate with my server on each request. The first step from what I can understand is: Trigger Sign In with Apple on the client, send the idToken to the server and pass it to `authClient.signIn.social`. But I can't figure how to give the client something (possibly a JWT) that it can send with requests to my server and I can verify it and process the request.
Author
Owner

@productdevbook commented on GitHub (Feb 23, 2025):

I think a package for swift would be much more useful.

@productdevbook commented on GitHub (Feb 23, 2025): I think a package for swift would be much more useful.
Author
Owner

@CodeWithShreyans commented on GitHub (Feb 23, 2025):

Yeah but that's asking contributors for a lot of work. I just want a solution that may not be the easiest but works.

@CodeWithShreyans commented on GitHub (Feb 23, 2025): Yeah but that's asking contributors for a lot of work. I just want a solution that may not be the easiest but works.
Author
Owner

@CodeWithShreyans commented on GitHub (Feb 23, 2025):

@Bekacru Would #1515 be a better solution to this?

@CodeWithShreyans commented on GitHub (Feb 23, 2025): @Bekacru Would #1515 be a better solution to this?
Author
Owner

@Bekacru commented on GitHub (Feb 23, 2025):

Apple sing in should be accomplished through the id token. After you authenticate with signIn.social the response should contain token that you can stroe and send on subsequent requests as a bearer header. Make sure to use the bearer plugin so the server can read it (by default it only reads cookies).

@Bekacru commented on GitHub (Feb 23, 2025): Apple sing in should be accomplished through the id token. After you authenticate with `signIn.social` the response should contain `token` that you can stroe and send on subsequent requests as a bearer header. Make sure to use the [bearer plugin](https://www.better-auth.com/docs/plugins/bearer) so the server can read it (by default it only reads cookies).
Author
Owner

@CodeWithShreyans commented on GitHub (Feb 23, 2025):

And this token doesn't expire?

@CodeWithShreyans commented on GitHub (Feb 23, 2025): And this token doesn't expire?
Author
Owner

@Bekacru commented on GitHub (Feb 23, 2025):

it does depends on your session.expiresIn config but whenever you call /get-session with the token, its age gets extended.

@Bekacru commented on GitHub (Feb 23, 2025): it does depends on your `session.expiresIn` config but whenever you call `/get-session` with the token, its age gets extended.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#723