# OAuth reauthentication?

**URL:** <https://community.hubspot.com/t/oauth-reauthentication/96018>\
**Category:** APIs & Integrations\
**Tags:** oauth\
**Created:** [December 13, 2023, 6:57pm UTC](https://community.hubspot.com/t/oauth-reauthentication/96018 "2023-12-13T18:57:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BSierakowski](https://avatars.discourse-cdn.com/v4/letter/b/74df32/32.png) [@BSierakowski](https://community.hubspot.com/u/BSierakowski)\
**Post date:** [December 13, 2023, 6:57pm UTC](https://community.hubspot.com/t/oauth-reauthentication/96018/1 "2023-12-13T18:57:09Z")

</div>

Hey there,

I’m trying to build a bit of resillency in my Hubspot app by catching the “MISSING\_SCOPES” error and prompting the user to reauthorize—which would happen if I expand the functionality of the app to require additional oauth 2 scopes.

As I’m building this I don’t see a way to pass the hubspot portal ID during the authentication flow, which poses 2 problems:

1) They could accidentally chose the wrong portal, and

2) We need to match the new key to their existing team on the way back.

Is there a way to match an existing Hubspot account on the frontend as a reauth request or is it always the case that if the token granted doesn’t have the appropriate scopes they need to auth again from scratch?  
If that’s the case I can pass their existing team id and portal id in the scope and redo their token (and, check that they didn’t pick a different team!), but wondering if there’s a way to allow a user to redo an existing token instead of starting from scratch.

Thanks!

-Brian

---

<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:** [December 14, 2023, 9:09pm UTC](https://community.hubspot.com/t/oauth-reauthentication/96018/2 "2023-12-14T21:09:36Z")

</div>

Hi, @BSierakowski 👋

Thanks for your question. Based on the [OAuth](https://developers.hubspot.com/docs/api/working-with-oauth) and [Token management](https://developers.hubspot.com/docs/api/oauth/tokens) documentation, I don’t see a way to pass portal IDs this way.

I know myself and our community would be interested to hear how you got this worked out – no matter if you took a different route or if you found a solution that got you “close enough”. And we’ll leave this here in case our community members have any feedback for you.

Best,

Jaycee

---

<div class="post-metadata">

**Author:** ![BSierakowski](https://avatars.discourse-cdn.com/v4/letter/b/74df32/32.png) [@BSierakowski](https://community.hubspot.com/u/BSierakowski)\
**Post date:** [December 14, 2023, 10:33pm UTC](https://community.hubspot.com/t/oauth-reauthentication/96018/3 "2023-12-14T22:33:26Z")

</div>

Ah, yes, I hate it when I find a post that explains my problem and they just respond with “nevermind, I got it” 😂.

I appreciate you taking a look, I came to the same conclusion, and I think it’s by design that you can’t expand the scopes on a given token. If you change your scopes, a new token must be created, so I made a parallel code path to “authorization” called “reauthorization.”

The main difference is that I have a different `redirect_uri` and pass the `state` param in addition to client\_id and scope. In the state param I include the user’s `team_id`, which is their ID in our database, and their portal id.  
When the user successfully completes the oauth2 process they come back to the different redirect\_uri I verify that the portal\_id coming back from the oauth2 process matches the portal\_id we have for that team. If not, we let them know that they picked the wrong team to reauth, and if it does match we process the new oauth token in the same way we do a “new” token.  
Hope that makes sense—happy to provide more info if that’d be useful to the community!
