question

gsm-tommy avatar image
gsm-tommy asked bryanvargas commented

Clover auth Token returns the same token multiple times

I have implemented the Clover Authentication for the sandbox environment through a separate server app and then making request with the SDK generated token to that server app from the clover android app I'm building as well.

This is the method that does that;

private fun getCloverToken(callback: (String?) -> Unit) {
    account = CloverAccount.getAccount(this)

    object : AsyncTask<Void?, Void?, CloverAuth.AuthResult?>() {
        @Deprecated("Deprecated in Java")
        override fun doInBackground(vararg params: Void?): CloverAuth.AuthResult? {
            try {
                val context: Context = applicationContext
                return CloverAuth.authenticate(context)
            } catch (e: Exception) {
                Log.e(TAG, "getCloverToken()/doInBackground: $e")
            }
            return null
        }

        @Deprecated("Deprecated in Java")
        override fun onPostExecute(cloverAuth: CloverAuth.AuthResult?) {
            super.onPostExecute(cloverAuth)

            if (!isFinishing) {
                if (cloverAuth?.authToken != null) {
                    val cloverAccountToken = cloverAuth.authToken.toString()
                    callback(cloverAccountToken)
                } else {
                    Log.e(TAG, "getCloverToken()/onPostExecute: Error retrieving token.")
                    Toast(applicationContext).showCustomToast(getString(R.string.no_clover_account), this@MainActivity)
                    callback(null)
                }
            }
        }
    }.execute()
}


While everything was working previously, I am now experiencing issues with the authentication token. Specifically, the token is sometimes being returned even after it has expired, causing authentication to fail after 5 days or more.

Note that I'm not controlling the token expiration in the server app. I'm relying entirely on clover for validating and generating tokens. When a request is submitted with a clover token, I send a test call to the clover api to verify the token. If it's good, I allow the request.

OAuthauth tokens
3 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

bryanvargas avatar image bryanvargas ♦♦ commented ·

I might need a little more detail on this, Clover doesn't have expiring tokens in Sandbox (so the token will be the same). Do you mind providing the endpoint you are using to send a test call?

0 Likes 0 ·
gsm-tommy avatar image gsm-tommy bryanvargas ♦♦ commented ·
0 Likes 0 ·
bryanvargas avatar image bryanvargas ♦♦ gsm-tommy commented ·
So the token should be valid unless the merchant uninstalls the app or you updated permissions that you didn't have access to before and trying to access new data. I would suggest trying it again to see if you are still having an issue.
-1 Like -1 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community