Gracefully handling a refused/failed OAuth authentication


#1

I’ve built an integration into Hubspot’s marketing API and while it works great for anyone that has a proper account, I have many people that are using either the CRM only or the free/starter marketing plan which are not compatible with the scopes that I am asking for.

As a result, whenever they try to do an OAuth login they are sent to a screen saying that the authentication failed or they don’t have permission. It doesn’t look good on my part and it’s creating a ton of unneccesary support tickets. I’ve tried to put as much documentation around the button itself to inform users not to fill it out, but some still are.

In a perfect world, I’d prefer if there was a callback url for a failed authentication which I could then handle gracefully on my user interface.

Alternatively, a friendlier message telling them that their instance of Hubspot is not compatible with the API would also be nice.

At the moment, the only possible workaround I can think of is essentially having a websocket monitor it for an event and if the event isn’t trigged by the callback to kill it, but I’m still kinda struggling with it.