question

superdave avatar image
superdave asked David Marginian Deactivated commented

Getting APIKEY in Sandbox Ecomm using Python

In Python, I used the following endpoint to try to get the access token and move on to get APIKEY in the next step, sandbox merchant is logged in before start:


SB_HOST = https://sandbox.dev.clover.com

SB_MID = Sandbox MerchantID

SB_CLIENT_ID = Sandbox APP ID (installed by SB_MID)


url = "{}{}{}?client_id={}".format(SB_HOST, "/oauth/merchants/", SB_MID, SB_CLIENT_ID)

response = requests.get(url)


The url will look like the following:

https://sandbox.dev.clover.com/oauth/merchants/89XXXXB5691?client_id=7HXXXXWBJ


Two things I tried:

1) Copy and paste the URL and run it in a browser, and It will redirect me to the site preset in APP setting.

2) Run in Python, and response.text gives me a HTML page


Here is the question:

When I run it in a browser, the address bar shown the following:

https://preset_site/?merchant_id=89XXXXB5691&employee_id=7D08XXXXXX&client_id=7HXXXXWBJ#access_token=4xxxf-yyyy-zzzz-aaaa-bbbbbb


I used the access token shown in the address bar of the browser and test it in

https://docs.clover.com/clover-platform/reference/keys#getapikey

and get a 200 Response and gives me a JSON response:

{"apiAccessKey": "e1560xxxxxxxxxyyyyyyyf03523f1"

"merchantUuid": "89XXXX5691"

"developerAppUuid": "7HXXXXWBJ"

"active": true

"createdTime": 1587829007000

"modifiedTime": 1587829007000

}

This shown the access token is valid.


But, when I do it programatically, I cannot get the

https://preset_site/?merchant_id=89XXXXB5691&employee_id=7D08XXXXXX&client_id=7HXXXXWBJ#access_token=4xxxf-yyyy-zzzz-aaaa-bbbbbb


same as shown in the browser. If I can do it, I can programatically parse the access token from the string.


Am I doing something wrong? Please keep in mind this is ecommerce, NOT web app.

e-commerce apiOAuth
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.

superdave avatar image superdave commented ·

For sandbox testing, I chose Token (in APP settings), click on OAUTH EXAMPLE.

and will redirect me to a page with location showing access_token=xxxxxxx


I am now HARDCODE the access_token in testing, and can obtain APIACCESSKEY programmatically inside Python.


Am I in the right track?

0 Likes 0 ·

1 Answer

·
David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated commented

Just keep in mind in production you will need to follow the Oauth flow - https://docs.clover.com/clover-platform/docs/using-oauth-20. The token will be returned to you per the request in step three.

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

superdave avatar image superdave commented ·

So, in Testing, I can hardcode the access token in the code?

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

Whatever works for you.

0 Likes 0 ·

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