SW - Google Connect
Wordpress plugin for google oauth
Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/dazza-dev/sw-google-connect/archive/refs/heads/main.zipConecta una cuenta de Google por OAuth y provee el token de acceso a otros plugins. Genérico y reutilizable.
Description
Maneja únicamente la CONEXIÓN OAuth con Google (Client ID + Secret + Conectar) y
expone el token a otros plugins. El token puede autorizar cualquier API de Google
(Business Profile, Gmail, Calendar, Drive, etc.) según los scopes que pidan los
consumidores mediante el filtro swgc_scopes.
Reutilizable en varios proyectos: registra UNA app OAuth en tu Google Cloud, agrega el Redirect URI de cada sitio, y cada cliente conecta su propia cuenta.
Public API
swgc_is_connected(): boolswgc_access_token(): string|WP_Error— token válido, refrescado automáticamenteswgc_api_get($url): array|WP_Error— GET autenticado (JSON)swgc_api_post($url, $body): array|WP_Error— POST autenticado (JSON)swgc_disconnect(): void
Filtro para pedir scopes (aplica al conectar):
add_filter('swgc_scopes', function ($scopes) {
$scopes[] = 'https://www.googleapis.com/auth/business.manage';
return $scopes;
});
Requisitos (lado Google)
- App OAuth (Client ID + Secret) en Google Cloud, con el Redirect URI del sitio.
- Pantalla de consentimiento con los scopes que se vayan a usar (publícala para un refresh token permanente; en modo "Testing" expira a los 7 días).
Changelog
1.0.0
- Conexión OAuth con Google (authorization code + refresh token) y API pública (swgc_access_token / swgc_api_get / swgc_api_post).