Connected App showing correct scopes using "Optional Scopes"I’m trying to create webhook subscriptions for custom objects via the API.
I know that I need the `crm.objects.custom.read` scope in order to do so, so I am requesting it as part of my OAuth flow.
I have tried two approaches:
1. I have tried to request the `crm.objects.custom.read` has a conditionally required scope in my application. When I then later go to ask for this scope in the install URL, I see it in the consent screen, but later on, when I try to subscribe to a webhook, I get a scope missing error citing this scope. I note that when I go into my testing app and look at my connected application, I do not see anything except my configured required scopes.
2. i have tried to request the same scope in the optional scopes section, and request them per the documentation (ie, putting them in the optional scope parameter), I see the same issue. I see them in the consent screen, and this time, I see them in the connected application card, but I still get the scope issue when I try to hit the API end point:
```
{“status” => “error”,
“message” => “To subscribe to these events your app must require certain scopes defined in \“errors\”. Update your app’s auth configuration to fix this.”,
“correlationId” => “”,
“errors” =>
[{“subCategory” => “SubscriptionErrors.REQUIRED_SCOPE_SUBSCRIPTION_DETAIL”,
“message” =>
“subscriptionType 'custom_object_name.creation requires one of scopeCandidates on configured app: `[RequiredScopeGroup{id=55, name=crm.objects.custom.read, shortDescription=View custom object records, version=GRANULAR, visibility=VISIBLE}]`”,
“context” =>
{“subscriptionType” => [“custom_object_sample.creation”],
“scopeCandidates” => [“[RequiredScopeGroup{id=55, name=crm.objects.custom.read, shortDescription=View custom object records, version=GRANULAR, visibility=VISIBLE}]”]}}],
“category” => “VALIDATION_ERROR”,
“subCategory” => “SubscriptionErrors.REQUIRED_SCOPES_SUBSCRIPTION_FAIL”}
```
The only case where I have had success is when I put the scope in my “required” scope configuration. However, we have clients connecting at the “Professional” level, so not all our clients that we integrate with have access to custom objects, which are only available in enterprise.
My understanding is then that I should request this scope as “Condiitonally Required” but that does not seem to work.
I know I have the scope, as I can read said object using the `crm/v3/objects/objectType/objectId`
@crespireCrypto signals wrote:
Connected App showing correct scopes using "Optional Scopes"I’m trying to create webhook subscriptions for custom objects via the API.
I know that I need the `crm.objects.custom.read` scope in order to do so, so I am requesting it as part of my OAuth flow.
I have tried two approaches:
1. I have tried to request the `crm.objects.custom.read` has a conditionally required scope in my application. When I then later go to ask for this scope in the install URL, I see it in the consent screen, but later on, when I try to subscribe to a webhook, I get a scope missing error citing this scope. I note that when I go into my testing app and look at my connected application, I do not see anything except my configured required scopes.
2. i have tried to request the same scope in the optional scopes section, and request them per the documentation (ie, putting them in the optional scope parameter), I see the same issue. I see them in the consent screen, and this time, I see them in the connected application card, but I still get the scope issue when I try to hit the API end point:
```
{“status” => “error”,
“message” => “To subscribe to these events your app must require certain scopes defined in \“errors\”. Update your app’s auth configuration to fix this.”,
“correlationId” => “”,
“errors” =>
[{“subCategory” => “SubscriptionErrors.REQUIRED_SCOPE_SUBSCRIPTION_DETAIL”,
“message” =>
“subscriptionType 'custom_object_name.creation requires one of scopeCandidates on configured app: `[RequiredScopeGroup{id=55, name=crm.objects.custom.read, shortDescription=View custom object records, version=GRANULAR, visibility=VISIBLE}]`”,
“context” =>
{“subscriptionType” => [“custom_object_sample.creation”],
“scopeCandidates” => [“[RequiredScopeGroup{id=55, name=crm.objects.custom.read, shortDescription=View custom object records, version=GRANULAR, visibility=VISIBLE}]”]}}],
“category” => “VALIDATION_ERROR”,
“subCategory” => “SubscriptionErrors.REQUIRED_SCOPES_SUBSCRIPTION_FAIL”}
```
The only case where I have had success is when I put the scope in my “required” scope configuration. However, we have clients connecting at the “Professional” level, so not all our clients that we integrate with have access to custom objects, which are only available in enterprise.
My understanding is then that I should request this scope as “Condiitonally Required” but that does not seem to work.
I know I have the scope, as I can read said object using the `crm/v3/objects/objectType/objectId`
You can’t use optional/conditionally required scopes for webhook subscriptions in HubSpot — the API requires the scope to be listed under required scopes in your app configuration. Optional scopes work for making API calls, but webhook subscriptions validate only against required scopes. To support clients without custom objects, you’ll need to create separate apps or dynamically request scopes and enable webhooks only when the required scope is granted.
Hi @jlorienz, I hope that you are well!
Thanks for your contribution on the Community!
Hi @crespire, can you please confirm that the suggestions from @jlorienz work for you, please?
Thanks and have a great weekend!
Bérangère, HubSpot Community Manager