question

wlane avatar image
wlane asked wlane commented

Get test api token without callback url

Hi,

Is it possible to generate a valid api-token for Rest calls without going through the deployment of the app and a valid callback URL?

Here are few points that confuse me.

1- I would like to test the API, but don't have a secure URL to add in my app settings to receive the `code` (step 2 of this page https://docs.clover.com/clover-platform/docs/using-oauth-20). Can I get it in another way, just for testing?

2- Furthermore, when I go on

https://sandbox.dev.clover.com/oauth/authorize?client_id=48FV6PX3TCTWE

(that's my APP_ID) and I log in, I get a pop-up error "Not found".

3- When I look at the "Installs" menu, I can see that my own test-merchant account has installed my app.

4- Last, I did create an API_KEY in my Setup>Merchants menu, but I don't get how to use that one either.

Thanks

[EDIT]

I also tried

curl --request GET \
https://apisandbox.dev.clover.com/v3/merchants/ZM4SDMBTC5X31/payments \
-H 'accept: application/json' \
-H 'Authorization: Bearer b6fdc1ab-****' \ # This is the APi_KEY I get from my dashboard

And I get


{"message":"401 Unauthorized"}

[/EDIT]

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

1 Answer

David Marginian avatar image
David Marginian Deactivated answered wlane commented

First, the merchant id you are using does not exist in sandbox, it exists in prod. You need to make sure you are making calls to the correct environment.

To obtain a token, login to your test merchant's dashboard. You should see your application which appears to be named "test" in the left side nav (if installed to your merchant correctly). Hit the test link and you will be redirected to your application (even if your app url is not set correctly). The access_token will be in the URL. This works because your application is set to use "Token" for its Default OAUTH response, which is for testing only.

Using a valid, non-testing token is not much harder. First login to your developer dashboard. Select your application "test" (from the left nav) and then select the edit icon next to REST Configuration. Set the value for Default OAUTH Response to code instead of token and save the changes. Next follow the steps in the second paragraph above. This time instead of seeing an access_token in the url you will see a code. Now you will need to obtain an access_token from the code. Make a REST call to the Clover API outlined in Step 3 - Request an API Token - https://docs.clover.com/clover-platform/docs/using-oauth-20. You will need your app id, app secret and the code from above. The response of this call will be your access_token.

Note: If you are trying to make API requests from a web browser you will need to set the CORS Domain correctly or else the browser will reject the request.

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

wlane avatar image wlane commented ·

I recommend you copy your answer and paste it in the documentation page!

0 Likes 0 ·
wlane avatar image wlane wlane commented ·

@David Marginian how do I move this merchant to sandbox environment? I don't even know why it's in prod.

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

Do you have a developer account on sandbox? Just use your test merchant from when you created your sandbox account. If you don't have a developer account on sandbox you will need to create one.

0 Likes 0 ·
Show more comments

Welcome to the
Clover Developer Community