Deregister user¶
Deregister the user¶
Deregistering a user implies the removal of all his data (including access tokens and refresh tokens) from the device. The SDK will also send a request to the Token Server to revoke all tokens. The client credentials will remain stored on the device.
In order to call UserClient#deregisterUser
two arguments has to be passed:
UserProfile
object describing user which you want to deregister,OneginiDeregisterUserProfileHandler
handler that will indicate about the result of the deregistration.
Example code¶
Example code to deregister currently authenticated user:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
Handler methods¶
-
When
void onSuccess
is called then it's clear that user was successfully deregistered, so you should redirect user to a login screen. -
The method
void onError(final OneginiDeregistrationError oneginiDeregistrationError)
is called when some error happened during the action. For example the UserProfile was deleted from the device, but the request to the server failed. In such situation you would still want to redirect the user to the login screen, but you can also perform some additional action such as notifying.
Please note that you can handle errors that are relevant to you differently. To accomplish that you should compare the OneginiDeregistrationError#getErrorType()
value with the OneginiDeregistrationError
error type definitions. The OneginiDeregistrationError
will also contain an additional error description for
debugging and possibly a Throwable
object which you can get with the getMessage()
and getCause()
methods.