public class CloverAuth extends Object
CloverAuth.AuthResult.baseUrl
) and access token (see
CloverAuth.AuthResult.authToken
) used for REST API calls to the Clover cloud.
The information returned from authenticate(Context, boolean, Long, TimeUnit)
is
cached for 24 hours on the device. After 24 hours the information is validated
with the Clover cloud. This means that periodically, a call to
authenticate(Context, boolean, Long, TimeUnit)
will result in a blocking
network request. Your app should be prepared for this. Do not call this method
on the main UI thread, and be prepared to communicate any delays to the user.
Access tokens are guaranteed to be valid for at least 24 hours. There
is no situation where you can obtain an invalid access token from this method,
as long as your app is a valid Clover app in the Clover cloud and is installed
to this merchant.
The information returned from authenticate(Context, boolean, Long, TimeUnit)
should not be persisted or cached. Call this method prior to all request to the Clover cloud.
The forceValidate argument to authenticate(Context, boolean, Long, TimeUnit)
causes the token to be validated always, as opposed to every 24 hours as noted above.
Use of this is atypical.
The app invoking methods in this class must be published Clover developer app and be installed
to this merchant in the Clover cloud to succeed. It is not sufficient to only sideload an app.
See this Clover
documentation for more information about making REST API calls from a Clover app.Modifier and Type | Class and Description |
---|---|
static class |
CloverAuth.AuthResult
Container for the data returned when an account authenticates with the Clover service.
|
Modifier and Type | Field and Description |
---|---|
static String |
AUTH_AUTHORITY |
static Uri |
AUTH_URI |
static String |
METHOD_AUTH |
static String |
METHOD_AUTH_PERMISSIONS |
Constructor and Description |
---|
CloverAuth() |
Modifier and Type | Method and Description |
---|---|
static CloverAuth.AuthResult |
authenticate(Activity activity,
Account account)
Deprecated.
Use
authenticate(Context, boolean, Long, TimeUnit)
(required when targeting SDK level 26 or higher) |
static CloverAuth.AuthResult |
authenticate(Activity activity,
Account account,
boolean forceValidateToken)
Deprecated.
Use
authenticate(Context, boolean, Long, TimeUnit)
(required when targeting SDK level 26 or higher) |
static CloverAuth.AuthResult |
authenticate(Activity activity,
Account account,
boolean forceValidateToken,
Long timeout,
TimeUnit unit)
Deprecated.
Use
authenticate(Context, boolean, Long, TimeUnit)
(required when targeting SDK level 26 or higher) |
static CloverAuth.AuthResult |
authenticate(Context context)
Equivalent to calling
authenticate(Context, boolean, Long, TimeUnit) with
force validate false, and a timeout of 20 seconds. |
static CloverAuth.AuthResult |
authenticate(Context context,
Account account)
Deprecated.
Use
authenticate(Context, boolean, Long, TimeUnit)
(required when targeting SDK level 26 or higher) |
static CloverAuth.AuthResult |
authenticate(Context context,
Account account,
boolean forceValidateToken)
Deprecated.
Use
authenticate(Context, boolean, Long, TimeUnit)
(required when targeting SDK level 26 or higher) |
static CloverAuth.AuthResult |
authenticate(Context context,
Account account,
boolean forceValidateToken,
Long timeout,
TimeUnit unit)
Deprecated.
Use
authenticate(Context, boolean, Long, TimeUnit)
(required when targeting SDK level 26 or higher) |
static CloverAuth.AuthResult |
authenticate(Context context,
boolean forceValidateToken,
Long timeout,
TimeUnit unit)
Authenticates with the Clover service.
|
public static final String AUTH_AUTHORITY
public static final Uri AUTH_URI
public static final String METHOD_AUTH
public static final String METHOD_AUTH_PERMISSIONS
@Deprecated public static CloverAuth.AuthResult authenticate(Activity activity, Account account, boolean forceValidateToken) throws OperationCanceledException, AuthenticatorException, IOException
authenticate(Context, boolean, Long, TimeUnit)
(required when targeting SDK level 26 or higher)@Deprecated public static CloverAuth.AuthResult authenticate(Activity activity, Account account, boolean forceValidateToken, Long timeout, TimeUnit unit) throws OperationCanceledException, AuthenticatorException, IOException
authenticate(Context, boolean, Long, TimeUnit)
(required when targeting SDK level 26 or higher)activity
- the activity that initiated the authenticationaccount
- the account used for authenticationforceValidateToken
- flag for if token should be validated against API.
Increases response latency, use only when necessary.timeout
- the maximum time to waitunit
- the time unit of the timeout argument. This must not be null.OperationCanceledException
AuthenticatorException
IOException
authenticate(Context, boolean, Long, TimeUnit)
@Deprecated public static CloverAuth.AuthResult authenticate(Context context, Account account, boolean forceValidateToken) throws OperationCanceledException, AuthenticatorException, IOException
authenticate(Context, boolean, Long, TimeUnit)
(required when targeting SDK level 26 or higher)@Deprecated public static CloverAuth.AuthResult authenticate(Context context, Account account, boolean forceValidateToken, Long timeout, TimeUnit unit) throws OperationCanceledException, AuthenticatorException, IOException
authenticate(Context, boolean, Long, TimeUnit)
(required when targeting SDK level 26 or higher)@Deprecated public static CloverAuth.AuthResult authenticate(Activity activity, Account account) throws OperationCanceledException, AuthenticatorException, IOException
authenticate(Context, boolean, Long, TimeUnit)
(required when targeting SDK level 26 or higher)@Deprecated public static CloverAuth.AuthResult authenticate(Context context, Account account) throws OperationCanceledException, AuthenticatorException, IOException
authenticate(Context, boolean, Long, TimeUnit)
(required when targeting SDK level 26 or higher)public static CloverAuth.AuthResult authenticate(Context context) throws InterruptedException, ExecutionException, TimeoutException
authenticate(Context, boolean, Long, TimeUnit)
with
force validate false, and a timeout of 20 seconds.public static CloverAuth.AuthResult authenticate(Context context, boolean forceValidateToken, Long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
authenticate(Context)
over this method
as it provides reasonable defaults for arguments.
This method differs from authenticate(Context, Account, boolean, Long, TimeUnit)
in
that it does not require an Account
argument. If your app targets API 26 or higher
you MUST use this method over the variants that accept an account as your app will
be restricted from obtaining the Clover account from CloverAccount
(via
AccountManager
).context
- the context that initiated the authentication.forceValidateToken
- should the token should be validated against the Clover cloud?
Tokens are validated every 24 hours regardless of this flag.
Passing true here is atypical and is discouraged.timeout
- the maximum time to wait. If null, wait forever. Typically this call will
finish in the order of tens of milliseconds, however, every 24 hours
the access token is validated against the Clover cloud, causing this
call to result in a blocking network request that can take longer.unit
- the time unit of the timeout argument. If null, wait forever.InterruptedException
ExecutionException
TimeoutException