question

sayid avatar image
sayid asked David Marginian Deactivated edited

Impossible 403 error

W/System.err: com.clover.sdk.v1.ForbiddenException: status code: 403 Permission denied

I cant bypass this error when testing with android studios. I have read post about unistalling and installing things again but it doesn't seem to ever work. Is there a setting I have to activate to give my test app permissions?

Clover Flex
10 |2000

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

David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated edited

Generally this means that your app doesn't have the required permissions for the API call you are making. If you can provide the call you are making and your app id that would be helpful.

2 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.

sayid avatar image sayid commented ·
I'm not sure what you mean by app id I'm trying to make a request for items using the sdk.
0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ sayid commented ·

Are you trying to run your code on a Clover device? The Clover Android SDK is for building apps for a Clover device.

0 Likes 0 ·
sayid avatar image
sayid answered David Marginian Deactivated edited

Below is the entire code block, it almost exact from the getting start with android SDK guide clover provides


package com.example.cloverwallet;


import android.accounts.Account;
import android.os.AsyncTask;
import android.os.RemoteException;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.clover.sdk.util.CloverAccount;
import com.clover.sdk.v1.BindingException;
import com.clover.sdk.v1.ClientException;
import com.clover.sdk.v1.ServiceException;
import com.clover.sdk.v3.inventory.InventoryConnector;
import com.clover.sdk.v3.inventory.Item;

/*
2) To get or set any Clover data, go through Clover’s Connector classes,
   such as InventoryConnector.
*/

public class MainActivity extends AppCompatActivity {

    private Account mAccount;
    private InventoryConnector mInventoryConnector;
    private TextView mTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    protected void onResume() {
        super.onResume();

        mTextView = (TextView) findViewById(R.id.activity_main_text_view);


        // Retrieve the Clover account
        if (mAccount == null) {
            mAccount = CloverAccount.getAccount(this);
            Log.d("SOPL","Account retrieved");
            Log.d("SOPL", String.valueOf(mAccount));



            if (mAccount == null) {
                return;
            }
        }

        // Connect InventoryConnector
        connect();

        // Get Item
        new InventoryAsyncTask().execute();
    }

 /*
3) Disconnect from the Clover Connectors when you aren’t using them to
   follow Android best practices and let the connection end naturally.
*/

    @Override
    protected void onDestroy() {
        super.onDestroy();
        disconnect();
        Log.d("SOPL","Destoyed");

    }

    private void connect() {
        disconnect();
        if (mAccount != null) {
            mInventoryConnector = new InventoryConnector(this, mAccount, null);

            mInventoryConnector.connect();
            Log.d("SOPL", String.valueOf(mInventoryConnector));

            Log.d("SOPL","Connected");
        }
    }

    private void disconnect() {
        if (mInventoryConnector != null) {
            mInventoryConnector.disconnect();
            mInventoryConnector = null;
            Log.d("SOPL","Disconnected");

        }
    }

/*
4) Use async tasks when working with Clover Connector classes to minimize
   work on the main UI thread while fetching or changing data. See
   https://docs.clover.com/clover-platform/docs/clover-development-
   basics-android#section-async-tasks-and-executors.
*/

    private class InventoryAsyncTask extends AsyncTask<Void, Void, Item> {

        @Override
        protected final Item doInBackground(Void... params) {
            try {
                //Get inventory item
                Log.d("SOPL","About to grab");
                return mInventoryConnector.getItem("MXFFBQHQPZY3C");

            } catch (RemoteException | ClientException | ServiceException | BindingException e) {
                e.printStackTrace();
                Log.d("SOPL","Failed");

            }
            return null;
        }

/*
5) Set the TextView to display the item’s name. For other methods that Item
   objects have, see
   https://clover.github.io/clover-android-sdk/com/clover/sdk/v3/inventory
   /Item.html
*/

        @Override
        protected final void onPostExecute(Item item) {
            if (item != null) {
                mTextView.setText(item.getName());
                Log.d("SOPL","Name set");

            }
        }
    }
}



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.

David Marginian avatar image David Marginian ♦♦ commented ·
Ok, I need to know which call is failing, I can't look at 150 lines of code and guess. Also, what is your app id?
0 Likes 0 ·
sayid avatar image sayid David Marginian ♦♦ commented ·

Of course, my apologies line 112 failed

return mInventoryConnector.getItem("MXFFBQHQPZY3C");


As far as app ID don't believe I have one this is just a simple app to understand fundamentals. I haven't published anything its all remote

0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ sayid commented ·

A Clover app is required. How are you loading this apk onto the devkit? You can't just sideload it and expect it to work. Please read through our documentation to get a better idea of some of the basics - https://docs.clover.com/docs/clover-development-basics-android (all subsections), specifically https://docs.clover.com/docs/working-with-apks.

0 Likes 0 ·

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