question

javichaques avatar image
javichaques asked Jeffrey Blattman commented

Can't get access token from Android SDK

Hi,

I am trying to recover the access token but I am encountering this error. The same code has worked a few months ago but now it is not working.

Account account = CloverAccount.getAccount(context);
CloverAuth.AuthResult authResult = CloverAuth.authenticate(context, account);

Result:


I'm using Emulator with Clover Station 2018 profile.
Clover Android SDK 221.9

Am I doing something wrong or is it an issue?

Thanks
API TokenEmulatorClover Station 2018
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.

chanel avatar image chanel commented ·

Hi @javichaques, can you confirm some extra information for us? Is this a new emulator you've just set up or have you been using this particular emulator for development previously?

If this is new, have you associated the "device" to a test merchant (following the steps shown here)?

0 Likes 0 ·
Bryanne Vega avatar image Bryanne Vega commented ·
Lower your SDK version to 25 max.

In Android Oreo (8) there's a big difference in obtaining the Account, my suggestion is to keep the old SDK until further notice (I believe SDK 27 works too).
0 Likes 0 ·
yarrumretep avatar image yarrumretep commented ·
Hi @Chanel - I am having the same issue. I have associated the emulator with the sandbox account. I can confirm that the package matches the application definition and that the app-market indicates the app is installed on my virtual device. @Bryanne Vega I am getting a good account - confirmed that. Also tried backing down to v27, got the same result.

0 Likes 0 ·
Bryanne Vega avatar image Bryanne Vega yarrumretep commented ·

Try to uninstall the app, lower to version 25 of the SDK & reinstall/sideload.

Clean your project/build on your way too.

0 Likes 0 ·
Bryanne Vega avatar image
Bryanne Vega answered Jeffrey Blattman commented
Try to uninstall the app, lower to version 25 of the SDK & reinstall/sideload.
Clean your project/build on your way too.
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.

Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ commented ·

Just FYI we are working on providing an alternate interface to obtain the token that does not use account manager.

1 Like 1 ·
yarrumretep avatar image yarrumretep commented ·
@Bryanne Vega Checkout the github for the CloverAuth class - seems like it hasn't changed since March 2017. Doesn't this imply that rolling back to v25 would not change the execution of the call that is failing? https://github.com/clover/clover-android-sdk/blob/master/clover-android-sdk/src/main/java/com/clover/sdk/util/CloverAuth.java
0 Likes 0 ·
Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ yarrumretep commented ·

That's not how it works. Target SDK tells the Android OS what sort of compatibility layers to provide to your app. If you specify >=25, you are telling the OS you do not want the get accounts compatibility with older Android releases.

1 Like 1 ·
yarrumretep avatar image
yarrumretep answered
Solved this issue:
  1. Created a new app with a different package name on the sandbox developer portal
  2. Synchronized the app market on the virtual device - ensure new app shows in Installed Apps
  3. Rename the package in my AndroidManifest.xml and build.gradle to match the new app - also renamed the actual java package, though I'm not sure that is necessary.
  4. Rebuild and side-load.
  5. Rock n roll!
10 |2000

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