How to connect Square (Weebly) to API2Cart?
This guide provides a comprehensive, step-by-step instruction on how to connect Square (formerly Weebly) to API2Cart using Square's OAuth authorization. By following these steps, you will learn how to create a Square application, configure OAuth redirect URLs, and obtain the necessary Refresh Token to finalize your Square API integration.
Step 1: Create a Square Application
Square uses OAuth authorization to grant access to its API. To begin, you must create a new application in the Square Developer Console. This application will generate the credentials required for the integration.
Navigate to the Square Developer Console Applications page and click on the "Create Application" (or "+") button.
Fill in the required foundational fields for your application, including the application name, intended use cases, and target audience. Once completed, you will be redirected to your specific application's dashboard.
Step 2: Configure OAuth and Redirect URL
The Redirect URL is a crucial endpoint where Square will send the authorization response (including the authorization code) after a seller approves your application's access request. For detailed setup guidelines, refer to the official Square OAuth documentation.
In your application's dashboard, navigate to the OAuth tab in the left-hand menu. Here, you need to configure your Redirect URL for either the Production or Sandbox environment, depending on your integration testing phase.
On this same OAuth settings page, you will also find your Application ID (Client ID) and Application Secret (Client Secret). Copy and securely store these credentials, as they are mandatory for the next steps.
Step 3: Generate the Authorization URL
Next, you must prepare the Authorization URL. This is the link you will provide to sellers so they can review and grant the required permissions to your application.
The authorization link follows this exact template format:
https://connect.squareup.com/oauth2/authorize?client_id=<Application ID>&scope=<Scopes>&redirect_uri=<Redirect URL>&session=false&state=<CSRF Token>
Here is a detailed breakdown of the URL parameters:
- client_id: Your
Application IDobtained from the Square OAuth dashboard. - scope: A space-separated (or
+separated) list of permissions your application requires. You can find the full list of necessary scopes for API2Cart methods in the table at the end of this article. - redirect_uri: The exact
Redirect URLyou registered on the Square OAuth page. - session: For a production application, set this to
false. This ensures that sellers with multiple Square accounts are prompted to select the correct account to authorize. This parameter is ignored in the Sandbox environment. - state: A unique, random Cross-Site Request Forgery (CSRF) token generated by your server. Square will return this exact string in the response URL, allowing your application to verify the authenticity of the request.
Step 4: Seller Authorization and Obtaining the Code
Provide the generated Authorization URL to the seller. When the seller opens this link in their browser, they will be prompted to log into their Square account (if not already logged in) and review the permission request.
Upon clicking "Allow", the seller is immediately redirected back to your configured Redirect URL. The URL will now
contain an authorization code and the state parameter you initially provided.
Step 5: Exchange the Code for a Refresh Token
The authorization code has a short lifespan and must be exchanged for a Refresh Token via a secure server-to-server POST request.
Make an HTTP POST request to the Square token endpoint:
curl --location 'https://connect.squareup.com/oauth2/token' --header 'Content-Type: application/json' --data '{
"client_id": "<Application ID>",
"client_secret": "<Application Secret>",
"code": "<Authorization Code>",
"grant_type": "authorization_code",
"redirect_uri": "<Redirect URL>"
}'
A successful request will return a JSON response containing your refresh_token alongside an
access_token.
Step 6: Connect Square to API2Cart
With all credentials gathered, navigate to the API2Cart admin dashboard to finalize the Square integration. Open the "Add Connection" modal and select "Square (Weebly)" as the integration type.
Fill in the required fields using the data obtained in the previous steps:
- Square (Weebly) Client ID: Your Square
Application ID. - Square (Weebly) Client Secret: Your Square
Application Secret. - Square (Weebly) Refresh Token: The
refresh_tokengenerated in Step 5.
Table of Required Square OAuth Scopes for API2Cart Methods
Below is the comprehensive list of Square OAuth scopes required to successfully execute specific API2Cart methods.
| API2Cart Method | Required Square OAuth Scopes |
|---|---|
| cart.validate | ONLINE_STORE_SITE_READ |
| cart.info | ONLINE_STORE_SITE_READ, MERCHANT_PROFILE_READ, EMPLOYEES_READ
|
| product.list | ONLINE_STORE_SITE_READ, ITEMS_READ, INVENTORY_READ |
| product.info | ONLINE_STORE_SITE_READ, ITEMS_READ, INVENTORY_READ |
| product.add | ONLINE_STORE_SITE_READ, ITEMS_WRITE, INVENTORY_WRITE |
| product.update | ONLINE_STORE_SITE_READ, ITEMS_READ, ITEMS_WRITE,
INVENTORY_READ, INVENTORY_WRITE
|
| product.delete | ONLINE_STORE_SITE_READ, ITEMS_WRITE |
| product.image.add | ONLINE_STORE_SITE_READ, ITEMS_WRITE |
| product.image.update | ONLINE_STORE_SITE_READ, ITEMS_READ, ITEMS_WRITE |
| product.image.delete | ONLINE_STORE_SITE_READ, ITEMS_READ, ITEMS_WRITE |
| product.child_item.list | ONLINE_STORE_SITE_READ, ITEMS_READ, INVENTORY_READ |
| product.child_item.info | ONLINE_STORE_SITE_READ, ITEMS_READ |
| product.variant.add | ONLINE_STORE_SITE_READ, ITEMS_READ, ITEMS_WRITE,
INVENTORY_WRITE
|
| product.variant.update | ONLINE_STORE_SITE_READ, ITEMS_READ, ITEMS_WRITE,
INVENTORY_READ, INVENTORY_WRITE
|
| product.variant.delete | ONLINE_STORE_SITE_READ, ITEMS_WRITE |
| product.variant.image.add | ONLINE_STORE_SITE_READ, ITEMS_READ, ITEMS_WRITE |
| product.variant.image.delete | ONLINE_STORE_SITE_READ, ITEMS_READ, ITEMS_WRITE |
| category.list | ONLINE_STORE_SITE_READ, ITEMS_READ |
| category.info | ONLINE_STORE_SITE_READ, ITEMS_READ |
| category.add | ONLINE_STORE_SITE_READ, ITEMS_WRITE |
| category.update | ONLINE_STORE_SITE_READ, ITEMS_READ, ITEMS_WRITE |
| category.delete | ONLINE_STORE_SITE_READ, ITEMS_WRITE |
| category.assign | ONLINE_STORE_SITE_READ, ITEMS_READ, ITEMS_WRITE |
| category.unassign | ONLINE_STORE_SITE_READ, ITEMS_READ, ITEMS_WRITE |
| category.image.add | ONLINE_STORE_SITE_READ, ITEMS_READ, ITEMS_WRITE |
| category.image.delete | ONLINE_STORE_SITE_READ, ITEMS_READ, ITEMS_WRITE |
| customer.count | ONLINE_STORE_SITE_READ, CUSTOMERS_READ |
| customer.list | ONLINE_STORE_SITE_READ, CUSTOMERS_READ |
| customer.info | ONLINE_STORE_SITE_READ, CUSTOMERS_READ |
| customer.groups.list | ONLINE_STORE_SITE_READ, CUSTOMERS_READ |
| customer.add | ONLINE_STORE_SITE_READ, CUSTOMERS_WRITE |
| customer.update | ONLINE_STORE_SITE_READ, CUSTOMERS_READ, CUSTOMERS_WRITE |
| customer.delete | ONLINE_STORE_SITE_READ, CUSTOMERS_WRITE |
| order.list | ONLINE_STORE_SITE_READ, ORDERS_READ, CUSTOMERS_READ,
ITEMS_READ
|
| order.info | ONLINE_STORE_SITE_READ, ORDERS_READ, CUSTOMERS_READ,
ITEMS_READ
|
| order.status.list | ONLINE_STORE_SITE_READ |
| order.add | ONLINE_STORE_SITE_READ, ITEMS_READ, ORDERS_WRITE,
PAYMENTS_WRITE
|
| order.update | ONLINE_STORE_SITE_READ, ORDERS_READ, ORDERS_WRITE |