APIs & Integrations

APear
Participant

Connect to API via oAuth C#

Hi,

I've just checked and this nuget package which is recommended on the documentation doesn't seem to work with oAuth.

hubspot-net/HubSpot.NET: C# .NET Wrapper around the common HubSpot APIs. (github.com)

SquaredUp.HubSpot.NET

 

It says on the sample it does, but once I try to use it, do 

 

var api = new HubSpotApi("clientID", "clientSecret", "HubSpotAppID");

 

It says is expecting an API key instead.

 

Can someone please help?

 

Regards 

0 Upvotes
8 Replies 8
SShah72
Member

Connect to API via oAuth C#

Any updates on above? I am facing same issue as @APear .

@APear Do you find any solution? I am not able to generate the access token

0 Upvotes
MPTatFoodDays
Participant

Connect to API via oAuth C#

I've switched to using RestSharp -- a generic REST interface helper -- that works with the OAuth Private app.

 

Create your private all, add perminssions and copy the Access Token to use in your Token here:

 

public class HubSpotConnection
{
	private RestClient client;

	private const string Token = "pat-na1-{number}-{number}-{more}-{and}-{more}";

	public void ProcessAutomationTickets()
	{
		client = new RestClient("https://api.hubapi.com")
		{
			Authenticator = new OAuth2AuthorizationRequestHeaderAuthenticator(Token,"Bearer")
		};

		var request = new RestRequest("/crm/v3/objects/tickets");
		var response = client.GetAsync(request).Result;
	}
}

 

All about RestSharp here: https://restsharp.dev/intro.html#introduction

 

MPT

0 Upvotes
AAva
Member

Connect to API via oAuth C#

Hello!I did the same with RestClient, it works fine.

I used the examples from here https://developers.hubspot.com/docs/api/crm/contacts adapted for my use case.

If you choose the "Endpoints" tab You can find examples and also run test calls.

 

Hope it helps!

SDevelopment
Participant

Connect to API via oAuth C#

Was there any feedback on this? 

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Connect to API via oAuth C#

Hi @APear 👋 Thanks for reaching out. Hey @0divide @MichaelC @Vidar @gotmike do you have any experience here? 

 

Thank you for taking a look! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

AAva
Member

Connect to API via oAuth C#

Hi! I'm having the same issue as @APear .

I wanted to migrate from API Key To Private app for my solution , I managed to use the private app token for a simple getcontacts call using HttpClient (Bearer autorization and private app token) but I could NOT make it work for HubSpotApi calls that requires ApiKey (i tried  with OAUTH  var api = new HubSpotApi("clientID", "clientSecret", "HubSpotAppID"); It says is expecting an API key instead

I would be grateful for any advice.

APear
Participant

Connect to API via oAuth C#

Thank you @AAva

Glad to know I am not alone here 🙂

APear
Participant

Connect to API via oAuth C#

Hi Jaycee,

Thank you for this. 

Let's hope they can help.