feat: Switch to OAuth 2.0 authentication for Google Merchant API
- Replace service account authentication with OAuth 2.0 user flow - Add "Authorize with Google" button in admin settings - Handle OAuth callback and token exchange - Store refresh token for automatic access token renewal - Add revoke authorization functionality - Update admin UI to show authorization status - Update price updater to use new OAuth credentials - Add CSRF protection with state parameter This change supports organizations that have disabled service account key creation via iam.disableServiceAccountKeyCreation policy. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
bindEvents: function() {
|
||||
$('#informatiq-sp-manual-sync').on('click', this.handleManualSync);
|
||||
$('#informatiq-sp-test-connection').on('click', this.handleTestConnection);
|
||||
$('#informatiq-sp-revoke-auth').on('click', this.handleRevokeAuth);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -138,6 +139,46 @@
|
||||
}, 5000);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle revoke authorization button click
|
||||
*/
|
||||
handleRevokeAuth: function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var $button = $(this);
|
||||
|
||||
// Confirm action
|
||||
if (!confirm(informatiqSP.strings.revokeConfirm || 'Are you sure you want to revoke Google authorization?')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable button and show loading state
|
||||
$button.prop('disabled', true).text(informatiqSP.strings.revokeInProgress || 'Revoking...');
|
||||
|
||||
// Make AJAX request
|
||||
$.ajax({
|
||||
url: informatiqSP.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'informatiq_sp_revoke_auth',
|
||||
nonce: informatiqSP.nonce
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
// Reload page to show updated status
|
||||
location.reload();
|
||||
} else {
|
||||
alert('Error: ' + (response.data.message || 'Unknown error'));
|
||||
$button.prop('disabled', false).text('Revoke Authorization');
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
alert('Error: ' + errorThrown);
|
||||
$button.prop('disabled', false).text('Revoke Authorization');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user