Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions js/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,6 @@ export const ASSET_FORM_KEY = {
...ASSET_GROUP_KEY,
};

export const GOOGLE_WPCOM_APP_CONNECTED_STATUS = {
APPROVED: 'approved',
DISAPPROVED: 'disapproved',
ERROR: 'error',
DISABLED: 'disabled',
};

export const APP_RATINGS_BANNER_CONTEXT = 'app_ratings_banner';

export const PRICE_BENCHMARK_CHART_COLORS = {
Expand Down
23 changes: 0 additions & 23 deletions js/src/data/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* External dependencies
*/
import { apiFetch } from '@wordpress/data-controls';
import { addQueryArgs } from '@wordpress/url';
import { __ } from '@wordpress/i18n';

/**
Expand Down Expand Up @@ -432,21 +431,6 @@ export function* fetchGoogleAccount() {
}
}

/**
* Fetch the URL for the user to grant Google's WPCOM app access to WooCommerce product data etc.
*
* @param {'settings'|'setup-mc'} nextPageName The name of the next page to redirect to after authorization.
* @return {string} The URL for the user to continue authorization.
* @throws Will throw an error if the request failed.
*/
export function* fetchWPComAppAuthorizationUrl( nextPageName ) {
const query = { next_page_name: nextPageName };
const path = addQueryArgs( `${ API_NAMESPACE }/rest-api/authorize`, query );

const response = yield apiFetch( { path } );
return response.auth_url;
}

export function receiveGoogleAccountAccess( data ) {
return {
type: TYPES.RECEIVE_ACCOUNTS_GOOGLE_ACCESS,
Expand Down Expand Up @@ -585,13 +569,6 @@ export function* disconnectAllAccounts() {
type: TYPES.DISCONNECT_ACCOUNTS_ALL,
};
} catch ( error ) {
// Skip any error related to revoking WPCOM token.
if ( error.errors[ `${ API_NAMESPACE }/rest-api/authorize` ] ) {
return {
type: TYPES.DISCONNECT_ACCOUNTS_ALL,
};
}

handleApiError(
error,
__(
Expand Down
24 changes: 1 addition & 23 deletions js/src/data/test/disconnectAllAccounts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,7 @@ describe( 'Disconnect All Accounts', () => {
} );
} );

it( 'Ignore the error if its thrown from the authorize endpoint', async () => {
mockFetch.mockRejectedValue( {
errors: {
[ `${ API_NAMESPACE }/rest-api/authorize` ]: {
message:
'No token found associated with the client ID and user',
},
},
} );

const { result } = renderHook( () => useAppDispatch() );

const response = await result.current.disconnectAllAccounts();

expect( mockFetch ).toHaveBeenCalledTimes( 1 );
expect( mockFetch ).toHaveBeenCalledWith( {
path: `${ API_NAMESPACE }/connections`,
method: 'DELETE',
} );
expect( response ).toEqual( { type: 'DISCONNECT_ACCOUNTS_ALL' } );
} );

it( 'Throw the error if it is not related to the authorize endpoint', async () => {
it( 'Throws the error when the request fails', async () => {
mockFetch.mockRejectedValue( {
errors: {
[ `${ API_NAMESPACE }/ads/connection` ]: {
Expand Down
78 changes: 0 additions & 78 deletions js/src/hooks/useUpdateRestAPIAuthorizeStatusByUrlQuery.js

This file was deleted.

134 changes: 0 additions & 134 deletions js/src/hooks/useUpdateRestAPIAuthorizeStatusByUrlQuery.test.js

This file was deleted.

3 changes: 0 additions & 3 deletions js/src/pages/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { getQuery, getHistory } from '@woocommerce/navigation';
import { API_RESPONSE_CODES } from '~/constants';
import useMenuEffect from '~/hooks/useMenuEffect';
import useGoogleAccount from '~/hooks/useGoogleAccount';
import useUpdateRestAPIAuthorizeStatusByUrlQuery from '~/hooks/useUpdateRestAPIAuthorizeStatusByUrlQuery';
import { subpaths, getReconnectAccountUrl } from '~/utils/urls';
import { ContactInformationPreview } from '~/components/contact-information';
import TargetAudienceSection from '~/components/target-audience-section';
Expand Down Expand Up @@ -44,8 +43,6 @@ const Settings = () => {
// Make the component highlight GLA entry in the WC legacy menu.
useMenuEffect();

useUpdateRestAPIAuthorizeStatusByUrlQuery();

const { google } = useGoogleAccount();
const isReconnectGooglePage = subpath === subpaths.reconnectGoogleAccount;
const { hasFinishedResolution, hasGoogleMCConnection } =
Expand Down
54 changes: 0 additions & 54 deletions src/API/Google/Middleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -538,19 +538,6 @@ protected function get_server_url( string $name = '' ): string {
return $name ? trailingslashit( $url ) . $name : $url;
}

/**
* Get the Google Shopping Data Integration auth endpoint URL
*
* @return string
*/
public function get_sdi_auth_endpoint(): string {
return $this->container->get( 'connect_server_root' )
. 'google/google-sdi/v1/credentials/partners/WOO_COMMERCE/merchants/'
. $this->strip_url_protocol( $this->get_site_url() )
. '/oauth/redirect:generate'
. '?merchant_id=' . $this->options->get_merchant_id();
}

/**
* Get the URL for the Google SDI merchant update endpoint.
*
Expand Down Expand Up @@ -701,47 +688,6 @@ public function is_subaccount(): bool {
return boolval( $is_subaccount );
}

/**
* Performs a request to Google Shopping Data Integration (SDI) to get required information in order to form an auth URL.
*
* @return array An array with the JSON response from the WCS server.
* @throws NotFoundExceptionInterface When the container was not found.
* @throws ContainerExceptionInterface When an error happens while retrieving the container.
* @throws Exception When the response status is not successful.
* @see google-sdi in google/services inside WCS
*/
public function get_sdi_auth_params() {
try {
/** @var Client $client */
$client = $this->container->get( Client::class );
$result = $client->get( $this->get_sdi_auth_endpoint() );
$response = json_decode( $result->getBody()->getContents(), true );

if ( 200 !== $result->getStatusCode() ) {
do_action(
'woocommerce_gla_partner_app_auth_failure',
[
'error' => 'response',
'response' => $response,
]
);
do_action( 'woocommerce_gla_guzzle_invalid_response', $response, __METHOD__ );
$error = $response['message'] ?? __( 'Invalid response authenticating partner app.', 'google-listings-and-ads' );
throw new Exception( $error, $result->getStatusCode() );
}

return $response;

} catch ( ClientExceptionInterface $e ) {
do_action( 'woocommerce_gla_guzzle_client_exception', $e, __METHOD__ );

throw new Exception(
$this->client_exception_message( $e, __( 'Error authenticating Google Partner APP.', 'google-listings-and-ads' ) ),
$e->getCode()
);
}
}

/**
* Fetch incentive credits from the Google Ads API.
*
Expand Down
1 change: 0 additions & 1 deletion src/API/Site/Controllers/DisconnectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ protected function get_disconnect_callback(): callable {
'mc/connection',
'google/connect',
'jetpack/connect',
'rest-api/authorize',
'youtube/connection',
'google/onboarding/complete',
];
Expand Down
Loading
Loading