# Connect to API via oAuth C#

**URL:** <https://community.hubspot.com/t/connect-to-api-via-oauth-c/62621>\
**Category:** APIs & Integrations\
**Tags:** oauth\
**Created:** [August 9, 2022, 12:27pm UTC](https://community.hubspot.com/t/connect-to-api-via-oauth-c/62621 "2022-08-09T12:27:35Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![MPTatFoodDays](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mptatfooddays/32/196312_2.png) [@MPTatFoodDays](https://community.hubspot.com/u/MPTatFoodDays)\
**Post date:** [October 7, 2022, 2:26pm UTC](https://community.hubspot.com/t/connect-to-api-via-oauth-c/62621/7 "2022-10-07T14:26:26Z")

</div>

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:

```lia-code-sample
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](https://restsharp.dev/intro.html#introduction)

MPT

---

_[View the full topic](https://community.hubspot.com/t/connect-to-api-via-oauth-c/62621)._
