question

saurabh avatar image
saurabh asked chanel Deactivated commented

How to get Access Token for Test Merchant

Hello Team,

I am new to clover web app development.

I have read the https://docs.clover.com/build/oauth-2-0/ Auth document twice or thrice but didnt understand it fully sothat i can generate access token for my test merchant.

blow is the code i am using(PHP)

$appSecret="[appSecret]"; $appId="CN4SN5WTQ22BW"; if(!empty($GET)) { if(isset($GET['code'])) { makeCall("https://www.clover.com/oauth/token?clientid=$appId&clientsecret=$appSecret&code=".$_GET['code'],0,array()); } }

function makeCall($url=0,$method=0,$data=array()) { // Get cURL resource $curl = curl_init();

// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL =>$url,
    CURLOPT_SSL_VERIFYPEER=>0
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
if(!$resp){
     die('Error: "' . curl_error($curl) . '" - Code: ' . curl_errno($curl));
    }
// Close request to clear up some resources
curl_close($curl);
echo "<br/>".$url;
echo "<br/>".$resp;

}

When i run this i get error: {"message":"Unknown Client ID"}

I also tried to run url directly in browser but got the same error.

Please help

Thanks

Auth
10 |2000

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

Bejoy Nair avatar image
Bejoy Nair answered

If you want to do it for testing purpose, you can get it from Setup.

  1. GoTo Setup
  2. Left Side there as an option "API Token". From here you can create a token for testing.
10 |2000

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

Mark Mullan avatar image
Mark Mullan Deactivated answered saurabh commented

Another core issue is that your app ID CN4SN5WTQ22BW belongs to a Sandbox app, but your request is pointing toward our US_PROD API servers. Our sandbox and production environments know nothing about each other. Try changing your GET request to https://sandbox.dev.clover.com/oauth/token...

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.

Mark Mullan avatar image Mark Mullan commented ·

I'm also redacting your appSecret from your original post, because, well, it's supposed to stay secret :)

0 Likes 0 ·
saurabh avatar image saurabh commented ·

Hello mark,

Thanks for your help, its solved my issue. You are right its a sandbox app id and the test user is belongs to sandbox. Thanks again to remove app secret i should not disclose secret of my app publicly. Thank you very much.

0 Likes 0 ·
Mark Mullan avatar image Mark Mullan commented ·

Great! Thanks for your follow up.

0 Likes 0 ·

Welcome to the
Clover Developer Community