public interface StitchAuth extends Closeable
StitchCredentials, retrieving the current
user, and getting authentication provider clients to perform actions such as registering users
and creating user API keys.| Modifier and Type | Method and Description |
|---|---|
void |
addAuthListener(StitchAuthListener listener)
Adds a listener for any important auth event.
|
<ClientT> ClientT |
getProviderClient(AuthProviderClientFactory<ClientT> factory)
Gets a client for the given authentication provider.
|
<T> T |
getProviderClient(NamedAuthProviderClientFactory<T> factory,
String providerName)
Gets a client for the given named authentication provider.
|
StitchUser |
getUser()
Returns the currently logged in user; null if not logged in.
|
boolean |
isLoggedIn()
Returns whether or not there's a currently logged in user.
|
Task<StitchUser> |
loginWithCredential(StitchCredential credential)
Logs a user in with the given credentials associated with an authentication provider created
from
getProviderClient(AuthProviderClientFactory) or getProviderClient(NamedAuthProviderClientFactory, String). |
Task<Void> |
logout()
Logs out the currently logged in user.
|
void |
removeAuthListener(StitchAuthListener listener)
Removes a listener.
|
<ClientT> ClientT getProviderClient(AuthProviderClientFactory<ClientT> factory)
ClientT - The type of client to be returned by the factory.factory - The factory that will create a client for the authentication provider.<T> T getProviderClient(NamedAuthProviderClientFactory<T> factory, String providerName)
T - the type of client to be returned by the factory.factory - the factory that will create a client for the authentication provider.providerName - the name of the authentication provider.Task<StitchUser> loginWithCredential(StitchCredential credential)
getProviderClient(AuthProviderClientFactory) or getProviderClient(NamedAuthProviderClientFactory, String).credential - the credentials of the user to log in.Task containing user associated with the credentials if log in is successful.Task<Void> logout()
Task completing when logged out.boolean isLoggedIn()
@Nullable StitchUser getUser()
void addAuthListener(StitchAuthListener listener)
listener - the listener to add.StitchAuthListenervoid removeAuthListener(StitchAuthListener listener)
listener - the listener to remove.