# Many websites using one Square implementation?

**URL:** <https://developer.squareup.com/forums/t/many-websites-using-one-square-implementation/7325>\
**Category:** Questions\
**Created:** [October 20, 2022, 6:59pm UTC](https://developer.squareup.com/forums/t/many-websites-using-one-square-implementation/7325 "2022-10-20T18:59:09Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![acicali](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@acicali](https://developer.squareup.com/forums/u/acicali)\
**Post date:** [October 20, 2022, 6:59pm UTC](https://developer.squareup.com/forums/t/many-websites-using-one-square-implementation/7325/1 "2022-10-20T18:59:09Z")

</div>

Hey you there… yeah you - thanks for taking the time to read this. I sincerely appreciate you.

I work with a few hundred small businesses whose websites are hosted on a custom legacy PHP platform. One of them has requested that we provide Square support for website payments, and I’m sure we’ll have more.

Most of the sites currently use USAePay, [Authorize.net](http://Authorize.net), and similar payment gateways where all of the action happens server-side. Where I’ve run into trouble with Square is that it’s unclear to me what credentials our clients will need to provide to our application.

For development, I have an APPLICATION\_ID and a LOCATION\_ID that are married together and belong to a single account. These work for now, but it doesn’t seem correct that we’d ask our clients to create an _application_ within their account and provide us with the APPLICATION\_ID. They can’t use our APPLICATION\_ID though because it won’t work with their LOCATION\_ID.

I see other posters that were referred to the OAuth docs, is that our path forward? The problem that creates for us is that it seems we must add a REDIRECT\_URL to _our_ account as an application provider. In our case, that REDIRECT\_URL would be hosted on the client’s website and thus a different domain name each time. This implementation would send us down a path of creating a standalone service to manage these.

Is there a method we can use where our clients would log into their Square account and copy a key and/or secret and provide them to us one time? Or is OAuth our only path forward for accepting credit card payments for many client websites?

Thanks again for your time and expertise!

- Aaron

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [October 20, 2022, 7:17pm UTC](https://developer.squareup.com/forums/t/many-websites-using-one-square-implementation/7325/2 "2022-10-20T19:17:39Z")

</div>

👋 OAuth is definitely our recommended path forward. It isn’t ideal to ask each seller to create an application for their account. 🙂

---

<div class="post-metadata">

**Author:** ![acicali](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@acicali](https://developer.squareup.com/forums/u/acicali)\
**Post date:** [October 21, 2022, 2:51pm UTC](https://developer.squareup.com/forums/t/many-websites-using-one-square-implementation/7325/3 "2022-10-21T14:51:35Z")

</div>

Thanks Bryan!

For anyone else who stumbles on this post, one _really_ important detail that took me some digging to find is that you can specify the REDIRECT\_URL dynamically when you whisk your user away to the authorization URL in which they agree to your application’s access to their Square account.

This means that if your application exists on many domains, you can redirect each user back to their instance of the application. See here: [https://developer.squareup.com/docs/oauth-api/create-urls-for-square-authorization#create-the-authorization-url](https://developer.squareup.com/docs/oauth-api/create-urls-for-square-authorization#create-the-authorization-url)

---

<div class="post-metadata">

**Author:** ![acicali](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@acicali](https://developer.squareup.com/forums/u/acicali)\
**Post date:** [October 21, 2022, 4:07pm UTC](https://developer.squareup.com/forums/t/many-websites-using-one-square-implementation/7325/4 "2022-10-21T16:07:05Z")

</div>

It seems I spoke too soon… the “redirect\_uri” parameter in the authorization URL must _exactly_ match what’s been specified in your account within the developer dashboard… this essentially makes the parameter useless. It can only give Square the same URL, and the URL _must_ also be set in the account or the OAuth redirect fails.

@Bryan-Square - what purpose does the redirect\_uri even serve?

---

<div class="post-metadata">

**Author:** ![acicali](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@acicali](https://developer.squareup.com/forums/u/acicali)\
**Post date:** [October 21, 2022, 4:24pm UTC](https://developer.squareup.com/forums/t/many-websites-using-one-square-implementation/7325/5 "2022-10-21T16:24:26Z")

</div>

Thanks again for your help @Bryan-Square. Looking at other posts, it seems that the \<redirect\_uri\> parameter was changed to require an exact match within the past year. This seems like a silly choice for Square to have made. That parameter has a distinct purpose - for those who need to redirect their users dynamically (e.g. many websites using the same Square integration).

If Square’s developers determined that this parameter created a security vulnerability, they should have just removed it from existence. Keeping it in the docs but not mentioning that it provides no value is confusing.

Another poster ([New OAuth redirect\_url requirement for static URI](https://developer.squareup.com/forums/t/new-oauth-redirect-url-requirement-for-static-uri/3454)) has solved their “multi-domain multi-tenancy” application problem by sticking their tenant information into the CSRF token, redirecting to one canonical service URL, then redirecting again from their service URL to their tenant based on the information that was shoved into the CSRF token. I suppose I’ll go that same route, but it’d be good to understand the rationale behind Square’s choice in this matter.

---

<div class="post-metadata">

**Author:** ![acicali](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@acicali](https://developer.squareup.com/forums/u/acicali)\
**Post date:** [October 21, 2022, 4:36pm UTC](https://developer.squareup.com/forums/t/many-websites-using-one-square-implementation/7325/6 "2022-10-21T16:36:38Z")

</div>

And for posterity’s sake, this parameter was likely dishonored because it indeed creates a vulnerability, see here: [https://sec.okta.com/articles/2021/02/stealing-oauth-tokens-open-redirects](https://sec.okta.com/articles/2021/02/stealing-oauth-tokens-open-redirects)

My recommendation to Square is the following:

1. Remove the \<redirect\_uri\> parameter from your documentation altogether and completely disregard it in your implementation (instead of throwing an error during OAuth that it doesn’t match what’s set in the account). Simply redirect to the Redirect URL set within the account, throw an error if it’s not set.
2. Provide an additional parameter for multi-tenant applications (perhaps called “tenant\_id”) that will also be passed back to the server hosting the Redirect URL so that it can determine which tenant is being authorized. This will prevent future developers from having to concoct their own solution by embedding the tenant information within the CSRF.
3. Document for future developers of multi-tenant applications how this process can be made to work… that they must host a service for Redirect URL, and that service should verify the validity of the tenant\_id and if necessary, redirect to that tenant’s domain.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [October 21, 2022, 6:02pm UTC](https://developer.squareup.com/forums/t/many-websites-using-one-square-implementation/7325/7 "2022-10-21T18:02:45Z")

</div>

We’re constantly working to improve our features based on feedback like this, so I’ll be sure to share your request to the API product team. 🙂

---

<div class="post-metadata">

**Author:** ![acicali](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@acicali](https://developer.squareup.com/forums/u/acicali)\
**Post date:** [October 21, 2022, 6:20pm UTC](https://developer.squareup.com/forums/t/many-websites-using-one-square-implementation/7325/8 "2022-10-21T18:20:08Z")

</div>

Thanks Bryan. Another option that could be helpful would be an encrypted redirect\_uri parameter… encrypted via pre-shared key. This should remove the threat of open redirects.

---

<div class="post-metadata">

**Author:** ![jackharry11](https://avatars.discourse-cdn.com/v4/letter/j/eada6e/32.png) [@jackharry11](https://developer.squareup.com/forums/u/jackharry11)\
**Post date:** [October 25, 2022, 7:49pm UTC](https://developer.squareup.com/forums/t/many-websites-using-one-square-implementation/7325/9 "2022-10-25T19:49:37Z")

</div>

For anyone else who stumbles on this post, one _really_ important detail that took me some digging to find is that you can specify the REDIRECT\_URL dynamically when you whisk your user away to the authorization URL in which they agree to your application’s access to their Square account.

---

<div class="post-metadata">

**Author:** ![wootmoot](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/wootmoot/32/21_2.png) [@wootmoot](https://developer.squareup.com/forums/u/wootmoot)\
**Post date:** [October 25, 2022, 8:00pm UTC](https://developer.squareup.com/forums/t/many-websites-using-one-square-implementation/7325/10 "2022-10-25T20:00:29Z")

</div>

> For anyone else who stumbles on this post, one _really_ important detail that took me some digging to find is that you can specify the REDIRECT\_URL dynamically when you whisk your user away to the authorization URL in which they agree to your application’s access to their Square account.

This is not the case. You can only redirect a user to a registered redirect URL, and you cannot do this dynamically (with Square’s current implementation of OAuth 2.0).

Also, to give more reason why there is a `redirect_url` parameter, is that this is part of a standard OAuth 2.0 implementation. Some OAuth implementations support the ability to register multiple redirect URLs, so you would specify in the the query param which registered `redirect_url` you would are wanting to send to user to in your flow.

Square currently only supports having one registered OAuth redirect URL per application. So yes, it doesn’t quite seem as useful right now, but it is also expected by a lot of OAuth libraries to be available.
