Skip to content

Commit

Permalink
feat: add support for square sandbox oauth (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulkr authored Jun 28, 2024
1 parent c2f7e56 commit efa8e6e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion integrationos-platform-oauth/src/connections/square/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export const init = async ({ body }: DataObject): Promise<OAuthResponse> => {
redirect_uri: body.metadata?.redirectUri,
};

const response = await axios.post(`https://connect.squareup.com/oauth2/token`, requestBody);
const isSandbox = body.clientId.startsWith('sandbox-');
const baseURL = isSandbox ? 'https://connect.squareupsandbox.com' : 'https://connect.squareup.com';

const response = await axios.post(`${baseURL}/oauth2/token`, requestBody);

const {
data: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export const refresh = async ({ body }: DataObject): Promise<OAuthResponse> => {
refresh_token,
};

const response = await axios.post(`https://connect.squareup.com/oauth2/token`, requestBody);
const isSandbox = client_id.startsWith('sandbox-');
const baseURL = isSandbox ? 'https://connect.squareupsandbox.com' : 'https://connect.squareup.com';

const response = await axios.post(`${baseURL}/oauth2/token`, requestBody);

const {
data: {
Expand Down

0 comments on commit efa8e6e

Please sign in to comment.