Ditto 1.1.9
Public Member Functions | Properties | List of all members
DittoSDK.DittoAuthenticator Class Reference

Provides access to authentication information and methods for logging on to Ditto Cloud. Relevant when using an OnlineWithAuthentication or an Online identity. More...

Public Member Functions

async Task< DittoErrorLoginWithToken (string token, string provider)
 Log in to Ditto with a third-party token. More...
 
async Task< DittoErrorLoginWithCredentials (string username, string password, string provider)
 Log in to Ditto with a username and password. More...
 
IDittoObserver ObserveStatus (Action< DittoAuthenticationStatus > callback)
 Registers a callback that is called whenever the authentication status changes. More...
 
bool IsAuthenticated ()
 Query whether Ditto has a valid authentication token. This will only be true when using an OnlineWithAuthentication or an Online identity, after a successful login. If the authentication token is allowed to expire then it will return false instead. More...
 
void Logout (Action< Ditto > cleanupAction=null)
 Log out of Ditto. More...
 

Properties

DittoAuthenticationStatus Status [get]
 Gets the current authentication status.
 
string? UserId [get]
 Gets the currently logged-in user ID. More...
 

Detailed Description

Provides access to authentication information and methods for logging on to Ditto Cloud. Relevant when using an OnlineWithAuthentication or an Online identity.

Member Function Documentation

◆ IsAuthenticated()

bool DittoSDK.DittoAuthenticator.IsAuthenticated ( )
inline

Query whether Ditto has a valid authentication token. This will only be true when using an OnlineWithAuthentication or an Online identity, after a successful login. If the authentication token is allowed to expire then it will return false instead.

Returns
True if there is a valid login to the remote authentication service, otherwise false.

Deprecated: Use Status.IsAuthenticated instead.

◆ LoginWithCredentials()

async Task< DittoError > DittoSDK.DittoAuthenticator.LoginWithCredentials ( string  username,
string  password,
string  provider 
)
inline

Log in to Ditto with a username and password.

Parameters
usernameThe username component of the credentials used for log in.
passwordThe password component of the credentials used for log in.
providerThe name of the authentication provider.
Returns
A DittoError if the login attempt failed, otherwise null.

◆ LoginWithToken()

async Task< DittoError > DittoSDK.DittoAuthenticator.LoginWithToken ( string  token,
string  provider 
)
inline

Log in to Ditto with a third-party token.

Parameters
tokenThe authentication token required to log in.
providerThe name of the authentication provider.
Returns
A DittoError if the login attempt failed, otherwise null.

◆ Logout()

void DittoSDK.DittoAuthenticator.Logout ( Action< Ditto cleanupAction = null)
inline

Log out of Ditto.

This will stop sync, shut down all replication sessions, and remove any cached authentication credentials. Note that this does not remove any data from the store. If you wish to delete data from the store then use the optional cleanupAction argument to perform any required cleanup.

Parameters
cleanupActionAn optional action that will be called with the relevant Ditto instance as the sole argument that allows you to perform any required cleanup of the store as part of the logout process.

◆ ObserveStatus()

IDittoObserver DittoSDK.DittoAuthenticator.ObserveStatus ( Action< DittoAuthenticationStatus callback)
inline

Registers a callback that is called whenever the authentication status changes.

Returns
An IDittoObserver that you can use to stop this observation.

Property Documentation

◆ UserId

string? DittoSDK.DittoAuthenticator.UserId
get

Gets the currently logged-in user ID.

This will be null if there is no valid authentication or OnlineWithAuthentication/Online mode is not being used.

Deprecated: Use Status.UserID instead.