Logout¶
The Logout operation terminates user session and disassociates the AuthenticatedUser
role from the subsequent requests made by the client application.
Non-Blocking API¶
The method call does not block - it returns immediately. The AsyncCallback argument receives either the response or the fault returned by the Backendless servers.
public void Backendless.UserService.logout( AsyncCallback<Void> callback )
where
Argument | Description |
---|---|
callback |
an object which is notified when the server completes the logout operation or returns an error. The class must implement the AsyncCallback<Void> interface . |
Blocking API¶
public void Backendless.UserService.logout() throws BackendlessException;
Important
Users logged in with Facebook must be logged out using the logOut()
method on the Facebook's LoginManager class .
Errors¶
The following errors may occur during the Logout API call. See the Error Handling section for details on how to retrieve the error code when the server returns an error.
Error Code |
Description |
---|---|
2002 |
Version is disabled or provided wrong application info (application id or secret key) |
3007 |
Invalid application-id or version. |
3023 |
General error while executing logout. Error details should be available in the message property. |
Example¶
Non-Blocking API¶
// do not forget to call Backendless.initApp in the app initialization code
Backendless.UserService.login( username, password, new AsyncCallback<BackendlessUser>()
{
public void handleResponse( BackendlessUser user )
{
// user has been logged in
// now, let's logout
Backendless.UserService.logout( new AsyncCallback<Void>()
{
public void handleResponse( Void response )
{
// user has been logged out.
}
public void handleFault( BackendlessFault fault )
{
// something went wrong and logout failed, to get the error code call fault.getCode()
}
});
}
public void handleFault( BackendlessFault fault )
{
// login failed, to get the error code call fault.getCode()
}
});
Blocking API¶
// do not forget to call Backendless.initApp in the app initialization code
BackendlessUser user;
try
{
user = Backendless.UserService.login( username, password );
}
catch( BackendlessException exception )
{
// login failed, to get the error code, call exception.getFault().getCode()
}
try
{
// now log out:
Backendless.UserService.logout();
}
catch( BackendlessException exception )
{
// logout failed, to get the error code, call exception.getFault().getCode()
}