401 (Unauthorized) errors are fairly common and can occur for a variety of reasons. This article discusses ways to troubleshoot a 401 (unauthorized) error.
Sandbox and production are separate environments. Make sure that you are not mistakenly executing your request in the incorrect environment.
Any typos in your request may potentially cause a 401:
- Ensure that the access token is being passed correctly.
- Make sure that your merchant ID is correct. The merchant ID required for our REST API is a 13-character alphanumeric ID (for example: TC4DGCJW1K4EW). The merchant ID can be found by logging on to your merchant dashboard and selecting Setup > Merchants. The merchant ID is the alphanumeric string under your merchant name in the Merchant column.
Clover merchant data is protected by a permissions scheme which requires each merchant to approve access. In general our API does not distinguish between an unauthorized error (401 - expired/invalid token, etc.) and a permissions error (token has insufficient privileges - should be a 403), and will return a 401 in either case.
- Does your application request the correct permissions for the API you are calling? For example, if you are attempting to create a new order, but your app does not request the ORDERS_W permission, an error is returned.
- Was your application configured to request the permissions it requires at the time the application was installed? If you have modified the permissions after the application was installed, you will need to uninstall and re-install the application and then generate a new access token using the OAuth flow. This is necessary to protect our merchants as they accept the permissions and terms of your application when they install it.
- Log on to your test merchant's dashboard. If you are logged into your developer dashboard you can navigate to your test merchant's dashboard using the dropdown at the top of the page (to the right of the Clover logo). Expand the dropdown and then select your test merchant under the Businesses section.
- On the side nav, select More Tools > Installed Apps.
- Find your application in the list (you may need to scroll with Next) and click it.
- On the right side of the application page, select ⋮ > Uninstall App.
- Log on to your developer dashboard.
- Select your application and then click Market Listing.
- On the market listing page, click PREVIEW IN APP MARKET.
- On the app market preview page, click Connect and then accept the terms of your application.
Is your application's Default OAuth Response set to Code or Token? This setting is found in your developer dashboard under REST Configuration in your application's settings. If your application's OAuth response is set to Code, you must obtain an access token by going through the entire OAuth flow (steps 1-5).
If it is set to Token, you will receive the access token directly in step 2 of the OAuth flow.
Using a token is only allowed when testing in sandbox.
If your application's Default OAuth Response is set to Code, ensure that you have completed all steps of the OAuth flow. The "code" received in step 2 is not an access token. If you try to pass this code as an access token, you will receive a 401.
Merchant tokens do not support CORs. If you are using a merchant token and making a call directly from a web browser, your request will fail. You will either need to proxy Clover API requests through your server or use an OAuth token.
Updated 23 days ago