APIs & Integrations

Richard_Wein
Member

OAuth - retrieving authorization code from redirect URI

Hi. I'm new here. I'd appreciate some help with OAuth from someone more experienced with it.

I'm developing an Excel VBA app that will fetch data from a Hubspot account into a spreadsheet. It's just a small thing for use within one company.

I've got the authorization working, but it's a bit hacky. Since my app is not a web app, it's not convenient to have a dedicated web address for the redirect. At the moment, during development, I'm just using "https://www.example.com/" as the redirect URI, and then asking the user to copy/paste the authorization code from their browser address bar into an Excel dialog box. I'd like to know if there's any better way of doing it.

I believe there may be a way of getting the URL back from Internet Explorer (though I haven't looked into it). But I don't want to rely on my users having IE available.

Any ideas would be welcome.

0 Upvotes
2 Replies 2
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

OAuth - retrieving authorization code from redirect URI

Hi @Richard_Wein,

You should only have to get the authorization code once, so using some generic URI might be the best way to approach this issue. You could also try creating a simple web server on a hosting service; services like Heroku have free tiers that might work for your purposes.

0 Upvotes
Richard_Wein
Member

OAuth - retrieving authorization code from redirect URI

Thanks for the reply, Derek.

I've decided to stick with using www.example.com as the redirect URI. But now, instead of opening the user consent page in the user's default browser, I'm using Internet Explorer. I have more control over that, and can automate the process of extracting the returned URL with the authorization code. If Internet Explorer isn't available (which I think is unlikely), then I fall back on opening the default browser and asking the user to copy/paste the authorization code. This compromise will be good enough for my needs.