Menu

How to revoke Sign in with Apple tokens when deleting a Supabase account
📰

How to revoke Sign in with Apple tokens when deleting a Supabase account

DEV Community: swift·Robert Long·6 days ago
#MrbMAJ1A
#devtoswift#devto#dev#apple#sign
Reading 0:00
15s threshold

If your iOS app offers Sign in with Apple, Apple asks you to revoke the person's token when they delete their account. With Supabase that's awkward: native sign-in uses signInWithIdToken , so you never receive an Apple refresh token, and at deletion time you have nothing to revoke.

Here's an approach that works without storing anything from Apple.

The idea

When the person taps Delete Account , show the Sign in with Apple sheet once more. It returns a fresh authorization code, valid for five minutes and usable once.

Send that code to a Supabase Edge Function.

The function exchanges the code for a refresh token at https://appleid.apple.com/auth/token .

It revokes that token at https://appleid.apple.com/auth/revoke .

Only then does it delete the Supabase user.

What you need

A Sign in with Apple key ( .p8 ) from Certificates, Identifiers & Profiles > Keys , plus its Key ID and your Team ID.

Those stored as Edge Function secrets, never in the app.

A client secret for each request: a short-lived JWT…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.