Problem/Motivation
The HubSpot module allows users to specify custom OAuth scopes in the admin settings (hubspot_scope). However, these configured scopes are currently ignored when generating the authorization URL. Instead, the module always uses a hardcoded set of default scopes (oauth and forms), which prevents developers from requesting additional permissions required for their specific HubSpot application integration.
Steps to reproduce
- Install and configure the HubSpot module.
- Navigate to
/admin/config/services/hubspot. - Enter custom scopes in the "HubSpot Scope" field (e.g.,
contacts content). - Click "Connect HubSpot Account".
- Observe that the redirected HubSpot authorization page only requests the default scopes (
formsandoauth), ignoring the custom scopes entered in the configuration.
Proposed resolution
Update Hubspot::getAuthorizationUrl() to retrieve the hubspot_scope configuration. If custom scopes are provided, they should be exploded into an array and used for the authorization URL. If the configuration is empty, the module should fall back to the existing HUBSPOT_OAUTH2_SCOPES constant.
Remaining tasks
- Review the patch.
- Verify that custom scopes are correctly passed to HubSpot during the OAuth handshake.
- Confirm that the default scopes are still used when no custom scopes are defined.
User interface changes
None. The "HubSpot Scope" field already exists in the admin settings but was previously non-functional.
API changes
None.
Data model changes
None.
Issue fork hubspot-3587900
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
jeroent