question

souvikbose avatar image
souvikbose asked ·

API access token not working in sandbox

I have created and APP in the sandbox and granted all the permissions . But when I generate any access token via the Oauth callback url , the same token is not authorizing.

It keeps saying

{

"message": "401 Unauthorized"

}


SandboxAPI Token
1 comment
10 |2000 characters needed characters left characters exceeded

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

Is it possible you are trying to use the code as the token? Are you sure your request is to a sandbox and not production url? Can you provide details of the request that returns a 401 in a moderators only comment?

0 Likes 0 · ·
David Marginian avatar image
David Marginian answered ·

The developer had set the permissions after the app was installed. Please see:

https://community.clover.com/articles/23744/resolving-401-unauthorized-responses-when-making-a.html for troubleshooting 401s.

Share
10 |2000 characters needed characters left characters exceeded

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

souvikbose avatar image
souvikbose answered ·

This is the URL structure .
https://sandbox.dev.clover.com/v3/merchants/xxxxxxxxxxxx/orders?access_token=xxxx-xxx-xxxx-xxxx-xxxxxxxxxxxxxxx

body: {"customers":[{"merchant":{"id":"xxxxxxxxxxxx"},"orders":[],"metadata":{},"id":"cust12345","firstName":"Souvik","lastName":"Bose","marketingAllowed":true}],"lineItems":[{"item":{"id":"4DR5FK58ZVK6P"},"exchangedLineItem":{},"refund":{"orderRef":{},"device":{},"payment":{},"employee":{},"overrideMerchantTender":{},"serviceChargeAmount":{},"germanInfo":{},"appTracking":{},"cardTransaction":{"extra":{},"vaultedCard":{}},"transactionInfo":{"identityDocument":{"payment":{}},"promotionalMessage":{},"eCommTransactionInfo":{"storedCredentials":{}},"sepaElvTransactionInfo":{}},"merchant":{}},"printGroup":{},"id":"1","name":"Green Apple","price":20,"priceWithModifiers":20,"priceWithModifiersAndItemAndOrderDiscounts":20,"unitQty":1,"unitName":"lb","itemCode":"ITEM001","printed":true}]}

output :

{

"message": "401 Unauthorized"

}
Some points to be noted :

  1. I have generated an API token from the developer console and surprisingly it is working
  2. The tokens generated from the Oauth flow are not working
  3. I have tried tokens from both source with the only merchant id i have
  4. I have configured only one app and the Oauth flow is working fine

4 comments Share
10 |2000 characters needed characters left characters exceeded

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

Are you certain you are not using the code as the token? Are you certain that you didn't modify the app permissions AFTER you installed the app? If so you need to uninstall and re-install the app and then generate a new token.

0 Likes 0 · ·
souvikbose avatar image souvikbose David Marginian ♦♦ ·

The first thing I am pretty sure. The second thing how do i uninstall the app and reinstall ?

0 Likes 0 · ·

Welcome to the
Clover Developer Community