Hubspot recently added a Users API for managing user accounts. This pull request adds a new UsersClient class that adds support for each of the available API methods. This API notably requires OAuth permission scopes, and requests will fail without them. The returned errors are fairly clear about the issue when that happens. For example, here's the error when changing a user role requires access to the billing scope:
HubspotBadRequest:
Error validating request.
---- request ----
PUT api.hubapi.com/settings/v3/users/example@example.com?idProperty=EMAIL, [timeout=<class 'int'>]
---- body ----
<class 'NoneType'>
---- headers ----
<class 'dict'>
---- result ----
<class 'int'>
---- body -----
{"status":"error","message":"Error validating request.","correlationId":"848ea612-ba12-4f6d-aab6-4476d827089b","errors":[{"message":"App must have the billing-write scope to modify roles for paid seats."},{"message":"This role is unavailable and can't be assigned to a user. This can happen when an account upgrades or downgrades their plan."}],"category":"VALIDATION_ERROR"}
---- headers -----
<class 'http.client.HTTPMessage'>
---- reason ----
Bad Request
---- trigger error ----
<class 'NoneType'>
The prospector CI check is failing because pylint is erroneously identifying various types from the typing module as unsubscriptable. This isn't unique to the new users submodule, the same thing is happening with the unchanged companies, contacts, crm_associations, deals, lines, properties, and utils submodules.
Hubspot recently added a Users API for managing user accounts. This pull request adds a new
UsersClient
class that adds support for each of the available API methods. This API notably requires OAuth permission scopes, and requests will fail without them. The returned errors are fairly clear about the issue when that happens. For example, here's the error when changing a user role requires access to the billing scope:The prospector CI check is failing because pylint is erroneously identifying various types from the
typing
module as unsubscriptable. This isn't unique to the newusers
submodule, the same thing is happening with the unchangedcompanies
,contacts
,crm_associations
,deals
,lines
,properties
, andutils
submodules.