I continued to be plagued with a highly frustrating problem thats driving me crazy.

I have a problem whereby the token auth_token issued by my Android App is failing in my web-app.

This is the line of code from the Android App.

webview.loadUrl("https:/domainname.com/cloverlogin?authtoken=" + result.authToken + "&merchantid=" + result.merchantId +"&appid=" + result.appId);

Attached are two images I've captured from Genymotion. The first is when I use the authToken passed from the Android App which results in an error 401 when I attempt an API call. The second is when I hard code the authtoken to be the one created in Sandbox against this merchant. With the second image you can see the authtoken I've used is not the same as the one passed to my PHP endpoint . You can clearly see the auth_token passed from the Android app is failing with an error 401.

I have set all the permissions to ticked against the app and I have uninstalled and reinstalled the app several times. I have done this on both the Emulator and the Clover Station with the same results.

Any ideas?


image description image description


Here is all the code from my Android App


package com.fashionservers.www.fsinventorymanagement;

import android.accounts.Account;
import android.content.Context;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.view.Window;

import com.clover.sdk.util.CloverAccount;
import com.clover.sdk.util.CloverAuth;
import com.clover.sdk.v1.app.AppNotification;
import com.clover.sdk.v1.app.AppNotificationReceiver;

public class MainActivity extends AppCompatActivity {

private Account mAccount;

protected void onCreate(Bundle savedInstanceState) {



protected void onResume() {

    // Retrieve the Clover account
    if (mAccount == null) {
        mAccount = CloverAccount.getAccount(this);

        if (mAccount == null) {

        // Use this account to get the access token (and other Clover authentication data)

private void getCloverAuth() {
    // This needs to be done on a background thread
    new AsyncTask<Void, Void, CloverAuth.AuthResult>() {
        protected CloverAuth.AuthResult doInBackground(Void... params) {
            try {
                return CloverAuth.authenticate(MainActivity.this, mAccount);
            } catch (Exception e) {
            return null;

        protected void onPostExecute(CloverAuth.AuthResult result) {
            WebView webview = new WebView(getBaseContext());
            webview.setWebViewClient(new WebViewClient());

            webview.loadUrl("https://www.fashionservers.com/stores/clover_login?auth_token=" + result.authToken  + "&merchant_id=" + result.merchantId +"&app_id=" + result.appId);



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS" />

    android:label="Fashion Inventory"

    <activity android:name=".MainActivity">
            <action android:name="android.intent.action.MAIN" />

            <category ...

asked 2017-05-10 08:35:56 -0500

Robin W gravatar image

updated 2017-05-10 11:07:46 -0500


how you fetching auth token from android using oAuth or through clover android sdk?

Pavan gravatar image
Pavan 2017-05-10 10:51:16 -0500

Its from the Clover Android SDK .. I have added all the code from my Android APP back into my original question. Thanks

Robin W gravatar image
Robin W 2017-05-10 11:05:22 -0500

2 answers

Sort by  

that's the problem buddy which i also getting it is clover known issue It sounds like you're not receiving a valid token from your device due to the known issue clover have when the app is uninstalled then installed. you can check this


CloverAuth.authenticate(MainActivity.this, mAccount);

with this in your code

CloverAuth.authenticate(MainActivity.this,mAccount,true,70L, TimeUnit.SECONDS);

where forceValidateToken will get you the latest token timeout is for max wait time for response TimeUnit will be anything you want seconds, minute etc.

check this too for reference https://devask.clover.com/question/77...

answered 2017-05-10 11:13:41 -0500

Pavan gravatar image

updated 2017-05-10 11:27:23 -0500


I'll give it a try, that sounds helpful. I am a php/html/css/javascript developer, and I have zero experience with Android, the code above was kindly written for me by Sam from the clover support team, so I have been groping around in the dark with this one for a few weeks. Where are you based?

Robin W gravatar image
Robin W 2017-05-10 11:17:56 -0500

m from India, i will update statement for you just paste that :)

Pavan gravatar image
Pavan 2017-05-10 11:20:06 -0500

Pavan, you;re a star thanks for your help :)

Robin W gravatar image
Robin W 2017-05-10 11:21:16 -0500

welcome, check edited answer

Pavan gravatar image
Pavan 2017-05-10 11:23:05 -0500

OK are you saying .. replace my code

CloverAuth.authenticate(MainActivity.this, mAccount);

with this code

CloverAuth.authenticate(MainActivity.this,mAccount,true,70L, TimeUnit.SECONDS);

... do I need this stil? authenticate(Activity activity, Account account, boolean forceValidateToken, Long timeout, TimeUnit unit)

Robin W gravatar image
Robin W 2017-05-10 11:25:09 -0500

Thanks to Pavan, his suggestion has worked.

answered 2017-05-10 12:32:31 -0500

Robin W gravatar image