question

jeremyinvoiceasap avatar image
jeremyinvoiceasap asked sam Deactivated commented

Access Token is not valid

Hi there.

I am using the REST API in the sandbox, and the access token for the merchant is stated as no longer being valid.

I have tried uninstalling/reinstalling the app and refreshing the cache inside the app market, but each time the app is installed I retrieve the same access token.

Please help me clear this cache properly so I can retrieve a new access token.

10 |2000

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

1 Answer

sam avatar image
sam Deactivated answered sam Deactivated commented

For the time being, if you're grabbing the device auth token, use the method with three arguments, last being boolean to check the server for valid auth token.

//    AuthResult authenticate(Activity activity, Account account, boolean forceValidateToken, Long timeout, TimeUnit unit)

`token = CloverAuth.authenticate(getBaseContext(), CloverAccount.getAccount(getBaseContext()), true, 1000l, TimeUnit.MILLISECONDS).authToken;`
4 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.

Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ commented ·

And please, only pass the force argument if you get a failure, and implement it such that you will give up after some number of retries (don't get into a tight loop calling authenticate() with force=true).

0 Likes 0 ·
loyalzoo avatar image loyalzoo commented ·

Hey, android studio reports that he can't resolve authenticate method taking three arguments and it won't let me build apk too. Am i missing something? Is there another workaround?

Cheers

0 Likes 0 ·
sam avatar image sam commented ·

@Loyalzoo, can you post a code snippet?

0 Likes 0 ·
loyalzoo avatar image loyalzoo commented ·

Hey Sam, sorry for the delay, here is the snippet:

final Account account = CloverAccount.getAccount(context); try { final CloverAuth.AuthResult auth = CloverAuth.authenticate(context, account, true); } catch (OperationCanceledException | IOException | AuthenticatorException e) { e.printStackTrace(); }

Android studio reporting: "Cannot resolve method 'authenticate(android.context.Context, android.account.Account, boolean)'"

0 Likes 0 ·

Welcome to the
Clover Developer Community