<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Robert Long</title>
    <description>The latest articles on DEV Community by Robert Long (@truoutdoorz).</description>
    <link>https://dev.to/truoutdoorz</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4238109%2F8a6c96ed-592f-44d4-92bb-2b0091d28c38.jpg</url>
      <title>DEV Community: Robert Long</title>
      <link>https://dev.to/truoutdoorz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/truoutdoorz"/>
    <language>en</language>
    <item>
      <title>How to revoke Sign in with Apple tokens when deleting a Supabase account</title>
      <dc:creator>Robert Long</dc:creator>
      <pubDate>Wed, 11 Nov 2026 01:49:32 +0000</pubDate>
      <link>https://dev.to/truoutdoorz/how-to-revoke-sign-in-with-apple-tokens-when-deleting-a-supabase-account-9ml</link>
      <guid>https://dev.to/truoutdoorz/how-to-revoke-sign-in-with-apple-tokens-when-deleting-a-supabase-account-9ml</guid>
      <description>&lt;p&gt;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 &lt;code&gt;signInWithIdToken&lt;/code&gt;, so you never receive an Apple refresh token, and at deletion time you have nothing to revoke.&lt;/p&gt;

&lt;p&gt;Here's an approach that works without storing anything from Apple.&lt;/p&gt;

&lt;h2&gt;
  
  
  The idea
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;When the person taps &lt;strong&gt;Delete Account&lt;/strong&gt;, show the Sign in with Apple sheet once more. It returns a fresh authorization code, valid for five minutes and usable once.&lt;/li&gt;
&lt;li&gt;Send that code to a Supabase Edge Function.&lt;/li&gt;
&lt;li&gt;The function exchanges the code for a refresh token at &lt;code&gt;https://appleid.apple.com/auth/token&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;It revokes that token at &lt;code&gt;https://appleid.apple.com/auth/revoke&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Only then does it delete the Supabase user.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What you need
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A Sign in with Apple key (&lt;code&gt;.p8&lt;/code&gt;) from &lt;strong&gt;Certificates, Identifiers &amp;amp; Profiles &amp;gt; Keys&lt;/strong&gt;, plus its Key ID and your Team ID.&lt;/li&gt;
&lt;li&gt;Those stored as Edge Function secrets, never in the app.&lt;/li&gt;
&lt;li&gt;A client secret for each request: a short-lived JWT signed with the key using ES256. Web Crypto in the Edge runtime can sign it without a library.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On the Swift side, only ask for the code when the account has an Apple identity:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;identities&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;supabase&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;identities&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;identities&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;where&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provider&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"apple"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;appleAuthorizationCode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;AppleReauthorizer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;authorizationCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Things that trip people up
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use your &lt;strong&gt;bundle identifier&lt;/strong&gt; as &lt;code&gt;client_id&lt;/code&gt;, not a Services ID.&lt;/li&gt;
&lt;li&gt;The code is &lt;strong&gt;single use&lt;/strong&gt; and expires in five minutes, so request it right before calling the function.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Revoke before you delete.&lt;/strong&gt; If Apple rejects the code, the account still exists and the person can try again.&lt;/li&gt;
&lt;li&gt;After revocation, the next sign-in looks like a first sign-in, and Apple shares the name again.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The full implementation
&lt;/h2&gt;

&lt;p&gt;The complete Edge Function and Swift code are part of &lt;a href="https://robertlong3.gumroad.com/l/TruKit" rel="noopener noreferrer"&gt;TruKit&lt;/a&gt;, a SwiftUI + Supabase starter kit that also covers sign-in, a paywall for Stripe, StoreKit 2 or RevenueCat, and a MapKit view with real-time updates.&lt;/p&gt;

</description>
      <category>ios</category>
      <category>swift</category>
      <category>supabase</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
