question

webmaster2 avatar image
webmaster2 Suspended asked suresh773 sent

Testing REST API in sandbox, always returns 401 Unauthorized

Hello,

I'm trying to do this and getting "401 Unauthorized" no matter what I do.

I've done all the steps... I have Test Merchant, Test Merchant token w/ all permissions, Test Merchant ID.

I click "Try It!"...

https://docs.clover.com/reference/merchantgetmerchant

... just always returns 401 Unauthorized.

What's wrong? What am I missing please? I can make a screen movie if that helps.

(I have already read through this, no help sorry: https://docs.clover.com/docs/401-unauthorized )

Use the API reference

To make a sample REST API call using the Clover API reference:

  1. From the left navigation pane, select MERCHANTS > Get a single merchant.
  2. In the Path Params section, enter your test merchant ID in the mId field. Your test merchant ID is a thirteen-character sequence of numbers. See Locate your test merchant ID for more information.
  3. In the Authentication section, enter your access token in the Bearer field. This value is the test API token that you have generated in the sandbox Developer Dashboard.
  4. Click Try It. In the JSON output response, the name value is your test merchant’s name.
REST APIAPI 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.

bryanvargas avatar image
bryanvargas answered

You need to make sure your Token has the correct synced permissions. if you make changes to permissions after install you need to get a new token, i would recommend to generate a new token (uninstall/reinstall app from merchant)

10 |2000

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

webmaster2 avatar image
webmaster2 Suspended answered

Thanks for the help, bryanvargas. I posted another topic, HERE, and parquet76 is saying I don't need to create and app. Is that true? You can read in that topic what my situation is... I am trying to integrate Clover payments into my client's ecommerce site, using Hosted iframe to process payments.

So, regarding what you said re: permissions and getting a new token... parquet76 is saying generate an ecommerce token from the Test Merchant. I have done that, and the system doesn't allow any setting of permissions for an ecommerce token.

If you are talking about an "API Token" and not an "Ecommerce API Token", then yes, I can try that now as you say, delete the token, then create a new token, setting the permissions in that step. I don't think it's necessary to uninstall and then reinstall the app, correct? Again, parquet76 says I don't need an app.

thanks again for your help.

10 |2000

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

webmaster2 avatar image
webmaster2 Suspended answered

Just got this while trying to reply with more information... attack detected? !!

1713582229900.png

1713582278436.png


1713582229900.png (32.5 KiB)
1713582278436.png (9.7 KiB)
10 |2000

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

webmaster2 avatar image
webmaster2 Suspended answered webmaster2 Suspended edited

I just created a new API Token for the Test Merchant, giving it full permissions.

Then I tried this...

curl --request GET \
--url https://sandbox.dev.clover.com/v3/merchants/RCTSTAVI0010002 \
--header 'accept: application/json' \
--header 'authorization: Bearer 5963a4a9-d903-bdbb-b6f7-d472cd14358e'

which returns "401 Unauthorized", both when I tried it from HERE and from my server.

I will now delete the app from Test Merchant and reinstall the app. I doubt it will have any effect.

UPDATE: Nope, doesn't work. I have three API Tokens now for Test Merchant: all read, all write, and both all read/write. None of them work.

10 |2000

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

webmaster2 avatar image
webmaster2 Suspended answered hanzala commented

Whatever the case here, I am onto trying to set up an interactive form with HTML and javascript, in order to get a card token and create a charge, in the sandbox. See my other thread HERE.

Then I also need help creating an OAuth auth_token, to do the same test in the live environment.

I'm now trying to write some code that will accomplish that, I think... see my thread in the link.


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.

hanzala avatar image hanzala commented ·

Northshore Plaza is a modern shopping destination offering a diverse range of retail, dining, and lifestyle options to its visitors. The mall's convenient location and extensive amenities make it a popular spot for locals and tourists alike. With its opening hours typically running from 10 AM to 10 PM, Northshore Plaza ensures ample time for shoppers to explore and enjoy its various attractions.

http://northshoreplazasg.com/k-cuts/

0 Likes 0 ·
webmaster2 avatar image
webmaster2 Suspended answered

So it turns out I don't need an OAuth token. See details HERE.

10 |2000

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

eugenejorden avatar image
eugenejorden answered eugenejorden edited

Hello,

I understand your frustration with receiving a "401 Unauthorized" error while testing the REST API in the sandbox. It seems like you're encountering an authentication issue despite following all the necessary steps. One potential solution is to double-check your API token and ensure that it hasn't expired or that there are no additional headers required for authentication. Also, verify that you're using the correct environment (sandbox vs. production) URLs. In a similar vein, I faced a similar issue when integrating APIs for the gogoanime app, and the problem was resolved by re-generating the API token and ensuring the permissions were correctly set. Making a screen recording might indeed help pinpoint the issue more effectively.

Thanks!

10 |2000

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

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