# oAuth Security Question

**URL:** <https://community.hubspot.com/t/oauth-security-question/100665>\
**Category:** APIs & Integrations\
**Tags:** oauth\
**Created:** [February 21, 2024, 3:38pm UTC](https://community.hubspot.com/t/oauth-security-question/100665 "2024-02-21T15:38:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BLincoln2](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@BLincoln2](https://community.hubspot.com/u/BLincoln2)\
**Post date:** [February 21, 2024, 3:38pm UTC](https://community.hubspot.com/t/oauth-security-question/100665/1 "2024-02-21T15:38:32Z")

</div>

I’m just getting started with a POC of a public app. I’ve got the basic oAuth flow wired up but I feel like I’m not fully understanding something.  
What I’m thinking for basic architecture:  
- my app will live in the CRM in an iframe, triggered from a CRM card  
- my app receives the Hubspot userId via query string from the iframe’s src  
- my app loads, goes through the oAuth flow. Users do not authenticate on my app beyond Hubspot’s oAuth flow (is this typical?)  
- I store the refresh and access tokens in my db with the Hubspot userId as the primary key  
Now my question (and why I think I’m missing something), doesn’t this leave a pretty large vulnerability where users could change the userId in the query string. What prevents my app from sharing other users’ tokens?  
I can add some sort of rate limiting, etc. to mitigate but I’m wondering if I’m missing something more broadly. How do most apps handle this?  
Thanks!

---

<div class="post-metadata">

**Author:** ![Humashankar](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/humashankar/32/30856_2.png) [@Humashankar](https://community.hubspot.com/u/Humashankar)\
**Post date:** [February 21, 2024, 7:50pm UTC](https://community.hubspot.com/t/oauth-security-question/100665/2 "2024-02-21T19:50:01Z")

</div>

Will take some time to get some close solutions, meantime you can also refer to this artifacts which will help you the most:

> **[Working with OAuth - HubSpot docs](https://developers.hubspot.com/docs/apps/legacy-apps/authentication/working-with-oauth)**
>
> OAuth is a secure means of authentication for your app. It uses authorization tokens rather than a password to connect your app to a user account.
