Chinchilla-Software-Com/HubSpot.NET

Can't use oAuth

Closed this issue · 5 comments

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

Get Error CS1729 'HubSpotApi' does not contain a constructor that takes 3 arguments

Looks like oAuth has not been built but it seems to be part of your documentation.

Review the following for OAuth:

// Arrange
string clientId ;
string clientSecret ;
string redirectUri ;
string authCode ;

var oAuthApi = new HubSpotOAuthApi(HubSpotBaseClient.BaseUrl, clientId, clientSecret);

// Act
HubSpotToken token = oAuthApi.Authorize(authCode, redirectUri);

// Assert
Assert.IsFalse(string.IsNullOrWhiteSpace(token.RefreshToken), "No refresh token returned");
Assert.IsFalse(string.IsNullOrWhiteSpace(token.AccessToken), "No access token returned");

var api = new HubSpotApi(token);

H

Hi,

Thank you for this but I believe the object HubSpotOAuthApi doesn't seem to exist.

image

Should I download your code instead of the NuGet package?

Regards

Switch to the trunk or 1.0 branch. We are retiring master

Switch to the trunk or 1.0 branch. We are retiring master

Believe some progress has been made here.

I am now trying to query all the companies on our HubSpot account, but running in to more issues.

 using HubSpot.NET.Core;
using HubSpot.NET.Api;
using HubSpot.NET.Core.OAuth;
using HubSpot.NET.Core.OAuth.Dto;
using System.Diagnostics;
using HubSpot.NET.Api.Company.Dto;
using System.Collections.Generic;
using HubSpot.NET.Api.Company;

            string AppID = "1208045";
            string ClientID = "XXXXXXXX-XXX-XXX-XXX-096bc77e1f61";
            string ClientSecret = "XXXXXX-XXXXX-XXX-XXX-5a92b9e56e2e";
           string AuthCode = "xxxxxxxx-xxxx-xxxxx-b310-7cce3xxxxxx97e6";

            var oauthApi = new HubSpotOAuthApi(HubSpotBaseClient.BaseUrl, ClientID, ClientSecret);

            HubSpotToken token = oauthApi.Authorize(AuthCode, "");


            var api = new HubSpotApi(token);

            var companies = api.Company.GetByDomain<CompanyHubSpotModel>("squaredup.com", new CompanySearchByDomain()
            {
                Limit = 10
            });

I do not know where to get the authcode, and my redirect url on my app is not defined, so I am guessing I should only pass an empty string.

I also have an appID which I thought I would need.

if I pass a uid to the authcode it will through me an error with object not set.

I am guessing I am not seeing the full picture here.

I suggest you read the HubSpot OAuth docs - https://developers.hubspot.com/docs/api/working-with-oauth