Scheduler Meetings

ZevThreadly
Member

Background: Threadly is an app for Slack that allows users to broadcast/blast messages to multiple channels at once, and also includes action buttons to drive users towards CTAs, forms, and more. 

 

Issue: We're working on a HubSpot integration where a user can send out a message and include an action to their calendar. The message button opens a modal where the invitee fills out their info, selects a date and time, etc. 

 

The meeting schedule changes and availability calls work fine, however, when we try and make a POST to the booking endpoint, we get this error. Can somoene please advise? It appears from other posts in this forum that others are successful. 

 

{'status': 'error', 'message': "The scope needed for this API call isn't available for public use. If you have questions, contact support or post in our developer forum.", 'correlationId': 'ac9c1918-5a53-4dd4-9687-e09e4789305e', 'links': {'support': 'https://help.hubspot.com/', 'forum': 'https://community.hubspot.com/t5/APIs-Integrations/bd-p/integrations'}, 'category': 'MISSING_SCOPES'}

 

The access token has the following oauth scope: 

 

And here's the call: 

def book_hubspot_meeting(
    slug,
    first_name,
    last_name,
    email,
    start_time,
    duration,
    timezone,
    guest_emails=None,
    locale="en-us",
    likely_available_user_ids=None,
    hubspot_access_token=None
):
    """
    Book a HubSpot meeting using the Meetings API.

    Args:
        slug (str): Meeting link slug (e.g., "menelson")
        first_name (str): First name of the attendee
        last_name (str): Last name of the attendee
        email (str): Email address of the attendee
        start_time (int): Start time in milliseconds UTC (e.g., 1726059600000)
        duration (int): Duration in milliseconds (e.g., 1800000 for 30min)
        timezone (str): Timezone string (e.g., "America/New_York")
        guest_emails (list): Additional guest emails (optional)
        locale (str): Locale, default "en-us"
        likely_available_user_ids (list): List of likely available user IDs (optional)
        hubspot_access_token (str): OAuth Access token for HubSpot. If not provided, will look for environ HUBSPOT_ACCESS_TOKEN

    Returns:
        dict: Response from HubSpot API.
    """
    if hubspot_access_token is None:
        hubspot_access_token = os.environ.get("HUBSPOT_ACCESS_TOKEN")
        if not hubspot_access_token:
            raise ValueError("Missing HubSpot Access Token.")

    url = "https://api.hubapi.com/scheduler/v3/meetings/meeting-links/book"
    headers = {
        "Authorization": f"Bearer {hubspot_access_token}",
        "Content-Type": "application/json",
    }
    params = {
        "timezone": timezone
    }

    data = {
        "slug": slug,
        "firstName": first_name,
        "lastName": last_name,
        "email": email,
        "startTime": int(start_time),
        "duration": int(duration),
        "timezone": timezone,
        "locale": locale,
        "guestEmails": guest_emails if guest_emails is not None else [],
        "likelyAvailableUserIds": likely_available_user_ids if likely_available_user_ids is not None else [],
    }

    response = requests.post(url, headers=headers, params=params, json=data)
    try:
        return response.json()
    except Exception:
        return {"error": "Failed to parse HubSpot response", "status_code": response.status_code, "text": response.text}

 

ZevThreadly_0-1764961396442.png

 

0 Upvotes
1 Reply 1
SamTassey
Community Manager
Community Manager

Hi @ZevThreadly 

Welcome to the Community! 

 

I see your receiving the error 'The scope needed for this API call isn't available for public use' in your response. I found a couple of similar Community posts that you may find helpful in trouble shooting this! 

 

I'd also like to tag in some of our Top Contributors to see if they have any tips on this -- @GRajput, @SteveHTM, @evaldas, @RubenBurdin 

 

-- Do you have any suggestions for @ZevThreadly 

 

Thank you! 

 

Sam, Community Manager 

 

 


 

0 Upvotes