# Scope Error when testing auth with integration

**URL:** <https://community.hubspot.com/t/scope-error-when-testing-auth-with-integration/113435>\
**Category:** APIs & Integrations\
**Tags:** professional\
**Created:** [July 31, 2024, 10:00pm UTC](https://community.hubspot.com/t/scope-error-when-testing-auth-with-integration/113435 "2024-07-31T22:00:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SMaliska](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@SMaliska](https://community.hubspot.com/u/SMaliska)\
**Post date:** [July 31, 2024, 10:00pm UTC](https://community.hubspot.com/t/scope-error-when-testing-auth-with-integration/113435/1 "2024-07-31T22:00:40Z")

</div>

I am getting an error with my application right now and am unable to authenticate while testing due to an error that reads:

“Couldn’t complete connection. Authorization failed because the provided scopes are insufficient. Please contact the app developer.”

Thiis is my application:

[https://app.hubspot.com/developer/46358881/application/3405307](https://app.hubspot.com/developer/46358881/application/3405307/)

Here is the code we are using to authenticate:

```lia-code-sample
@NS_api.route('/hubspot')
class HubspotResource(Resource):
 @Api.doc(security=None, responses={200: 'Success', 401: 'Failed to get Hubspot token'}, description='Hubspot OAuth endpoint', params={'organization_id': 'Organization ID'})
 @handle_exceptions
 def get(self):
 # SCOPES must match the scopes in the Hubspot app
 HUBSPOT_SCOPES = ['crm.objects.contacts.read', 'crm.objects.contacts.write',
 'crm.objects.deals.read','crm.objects.deals.write','oauth']
 CLIENT_ID = os.getenv("HUBSPOT_CLIENT_ID")
 organization_id = request.args.get("organization_id")
 if organization_id:
 encoded_org_id = encode_entity_id(organization_id)
 org_param = f"&leadoff_state={encoded_org_id}"
 else:
 org_param = ""
 oauth = OAuth2Session(CLIENT_ID, scope=HUBSPOT_SCOPES, redirect_uri=os.getenv("BASE_URL") + "/hubspot-callback")
 authorization_url, state = oauth.authorization_url('https://app.hubspot.com/oauth/authorize')
 return jsonify({"redirect_url": authorization_url + org_param})

```

Any idea why this is happening or how we can correct it?

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [August 1, 2024, 3:14pm UTC](https://community.hubspot.com/t/scope-error-when-testing-auth-with-integration/113435/2 "2024-08-01T15:14:22Z")

</div>

Hey, @SMaliska 👋 Thanks for your question. As an additional troubleshooting step, have you tried collecting and analyzing a HAR file? Occasionally, the full missing scopes error can be revealed this way.

Basic steps:

- S[et up your browser to record a HAR](https://community.hubspot.com/t5/Tips-Tricks-Best-Practices/Troubleshooting-Toolkit-Collecting-a-HAR-file-and-Trace/m-p/20103)
- Step through the auth process until you get the error(s)
- Save the HAR file
- Analyze the file and look for more robust messaging about the issue ([Google HAR analyzer](https://toolbox.googleapps.com/apps/har_analyzer/))

This doesn’t always reveal the issue, but it’s a good next step to try if you haven’t already done so.

Best,

Jaycee
