Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added hubspotv2 scanner #2369

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ankushgoel27
Copy link
Contributor

Description:

This PR adds the new v2 version of the hubspot API key. The older version still works.
https://developers.hubspot.com/docs/api/settings/account-information-api

https://developers.hubspot.com/changelog/upcoming-api-key-sunset

https://knowledge.hubspot.com/integrations/how-do-i-get-my-hubspot-api-key

hubspotv2

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

@ankushgoel27 ankushgoel27 requested a review from a team as a code owner February 3, 2024 11:31
var (
client = common.SaneHttpClient()

keyPat = regexp.MustCompile(`\b(pat-na1-[A-Za-z0-9]{8}\-[A-Za-z0-9]{4}\-[A-Za-z0-9]{4}\-[A-Za-z0-9]{4}\-[A-Za-z0-9]{12})\b`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pat-na1-

I can't find official documentation for this, but it looks like there are region-specific prefixes including pat-na1- and pat-eu1-. It's possible there are others.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how did you find the pat-eu1 format? We can add these 2 formats for now and add more later?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any updates on this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you create an account, HubSpot prompts you to select either NA or EU. There's no specific documentation for the format, however, you can easily find examples by searching pat-eu1.

https://knowledge.hubspot.com/account-security/hubspot-cloud-infrastructure-and-data-hosting-frequently-asked-questions

@rgmz
Copy link
Contributor

rgmz commented May 13, 2024

@zricethezav Any chance this can get merged?

Copy link
Contributor

@rgmz rgmz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another observation.

Comment on lines +60 to +62
defer res.Body.Close()
if res.StatusCode >= 200 && res.StatusCode < 300 {
s1.Verified = true
Copy link
Contributor

@rgmz rgmz May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be updated to handle 403s, which indicate that a token is valid but missing scopes.

For example:

HTTP/2 403

{"status":"error","message":"This app hasn't been granted all required scopes to make this call. Read more about required scopes here: https://developers.hubspot.com/scopes.","correlationId":"...","errors":[{"message":"One or more of the following scopes are required.","context":{"requiredGranularScopes":["..."]}}],"links":{"scopes":"https://developers.hubspot.com/scopes"},"category":"MISSING_SCOPES"}

or

HTTP/2 403

{"status":"error","message":"This oauth-token (pat-na1-...) does not have proper permissions! (requires all of [contacts-read])","correlationId":"..."}

@rgmz rgmz mentioned this pull request Jun 18, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants