Sign in with Apple - problem when account is deleted

I'm currently working on a Swift app whose data storage and authentication part is managed by Firebase.

I would like to offer my users the possibility of using their Apple account for account creation.

To do this I added Apple as a “Connection Provider” in the Firebase console settings. 
 

 This part works without problem, when the user clicks on the “Sign in with Apple” button a popup appears asking if they agree to share this information (first and last name / email address) for account creation.



After entering the password, the user is authenticated and their account is created on Firebase.


 If I go to the iPhone settings in the Connection and Security section > Sign in with Apple, I can see my app in the list.


 Now my problem is at the time of deleting the user's account. When the account is deleted it no longer exists in Firebase as we expected.
  An email is also sent by Apple to warn that the application has revoked the account that had been created with “Sign in with Apple”.


And the application no longer appears in the list of applications in the Connection and Security > Connection with Apple from iPhone section. However, when I click on the “Sign in with Apple” button again, I don’t see the window that asks me if I want to share my connection information.

The app behaves as if I was simply logged out but when I enter my iCloud password I am logged in except in reality it is a new account. 
When I look in Firebase I have a new id for my user.
 

In addition, the user is not really connected to the application since certain views behave as if the user session was empty. The only way is to erase the emulator and make a new build.

I need help finding what's not working in my current code because I've been going around in circles for several days and I really don't understand what's going on.

Here my entire AuthentificationViewModel:

Answered by DTS Engineer in 789586022

Hi @Jeremy_Reynard,

You can programmatically invalid the user session, credentials and tokens by using the token/revoke endpoint. Please see the following documentation:

Revoke tokens

To make this POST request, you'll need to provide the user's refresh token or access token—you receive these in the TokenResponse when validating the authorization grant token or existing refresh tokens via the /auth/token endpoint documented below:

Generate and validate tokens

However, if you do not have the user's refresh token or access token, please see the following post:

Handling account deletions and revoking tokens for Sign in with Apple

Cheers,

Paris

Hi @Jeremy_Reynard,

You can programmatically invalid the user session, credentials and tokens by using the token/revoke endpoint. Please see the following documentation:

Revoke tokens

To make this POST request, you'll need to provide the user's refresh token or access token—you receive these in the TokenResponse when validating the authorization grant token or existing refresh tokens via the /auth/token endpoint documented below:

Generate and validate tokens

However, if you do not have the user's refresh token or access token, please see the following post:

Handling account deletions and revoking tokens for Sign in with Apple

Cheers,

Paris

Sign in with Apple - problem when account is deleted
 
 
Q