question

Alan avatar image
Alan asked Alan commented

Reinstalling an APK, updated auth token not working

Hi Clover, I needed to add some permissions to an existing app/apk, so I uninstalled and reinstalled with the extra permissions ticked and an updated apk build.

Two strange things happened:

  1. The updated auth token did change, but literally by 1 character (from: be687e0d-7540-15a1d-f1c2-f686f571e2cf to this: be687e0d-7540-151d-f1c2-f686f571e2cf notice the 15a1d and the new one is just missing the 'a')
  2. Neither of these auth tokens authenticate for me anymore (I had been using the Authorization header with the api for viewing merchant/inventory and creating payments up until reinstalling a few hours ago)

I'm aware that there's some changes being made to auth mid-april, but I believe i'm following the docs correctly (as i'm able to get this new auth token consistently after reinstalling)

import com.clover.sdk.util.CloverAuth;
import com.clover.sdk.v3.base.Reference;
import com.clover.sdk.v3.inventory.Modifier;
import com.clover.sdk.v3.order.Discount;
import com.clover.sdk.v3.order.LineItem;
import com.clover.sdk.v3.order.Modification;

...

public static Observable<CloverAuth.AuthResult> authenticateClover(Context context, Account mAccount) {
        return Observable.create(new Observable.OnSubscribe<CloverAuth.AuthResult>() {
            @Override
            public void call(Subscriber<? super CloverAuth.AuthResult> o) {
                CloverAuth.AuthResult authResult = null;
                try {
                    authResult = CloverAuth.authenticate(context, mAccount);
                } catch (OperationCanceledException | IOException | AuthenticatorException e) {
                    e.printStackTrace();
                    o.onError(e);
                }

                if(authResult != null && authResult.errorMessage != null){
                    o.onError(new Throwable(authResult.errorMessage));
                    o.onCompleted();
                } else {
                    o.onNext(authResult);
                    o.onCompleted();
                }
            }
        });
    }

Appreciate any help, Alan

Auth
1 comment
10 |2000

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

Alan avatar image Alan commented ·

I'm using a custom auth token as a workaround for the moment and it's working as expected for api calls.

0 Likes 0 ·

1 Answer

Jeffrey Blattman avatar image
Jeffrey Blattman answered Alan commented

There's a known bug where if an app is uninstalled and re-installed (from the Clover market's perspective), the auth token handed back to the newly installed app is invalid. The problem will resolve itself in 24 hours or less. A fix is rolling out soon. There's no workaround other than cleaning out all of the data from the com.clover.engine app (meaning on a Clover device factory reset, or on an emulator, re-logging back in to Clover).

1 comment
10 |2000

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

Alan avatar image Alan commented ·

Thanks @jeff

0 Likes 0 ·

Welcome to the
Clover Developer Community