Skip to content

feat: add datamachine_oauth_callback_url filter hook#1042

Merged
chubes4 merged 1 commit intomainfrom
feat/oauth-callback-url-filter
Apr 12, 2026
Merged

feat: add datamachine_oauth_callback_url filter hook#1042
chubes4 merged 1 commit intomainfrom
feat/oauth-callback-url-filter

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented Apr 12, 2026

Summary

  • Adds datamachine_oauth_callback_url filter to BaseAuthProvider::get_callback_url() so extension plugins can customize the OAuth redirect URI per provider
  • Applies the same filter to the legacy datamachine_get_oauth_callback_url() helper for consistency
  • Adds 3 tests covering filter behavior, slug passthrough, and provider isolation

Context

Closes #1041. Intelligence registers a WordPress.com OAuth provider (client_id 128117, shared with mcp-context-a8c) that expects /oauth/callback as the redirect path, not /datamachine-auth/wpcom/. This filter lets Intelligence hook in cleanly:

add_filter( 'datamachine_oauth_callback_url', function ( $url, $slug ) {
    if ( 'wpcom' === $slug ) {
        return site_url( '/oauth/callback' );
    }
    return $url;
}, 10, 2 );

Default behavior is unchanged — the filter passes through if no one hooks it.

Testing

All 19 BaseAuthProvider tests pass (16 existing + 3 new).

Add apply_filters('datamachine_oauth_callback_url', $url, $provider_slug) to
BaseAuthProvider::get_callback_url() so extension plugins can customize the
OAuth redirect URI per provider without subclassing. Also applied to the
legacy datamachine_get_oauth_callback_url() helper for consistency.
@chubes4 chubes4 merged commit bfd79df into main Apr 12, 2026
1 check passed
@chubes4 chubes4 deleted the feat/oauth-callback-url-filter branch April 12, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add filter hook for OAuth callback URL in BaseAuthProvider

1 participant