Skip to content

Commit da34fc3

Browse files
committed
HubSpot FormController uses ApiKey as Private App Token
1 parent 8605e49 commit da34fc3

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/Umbraco.Cms.Integrations.Crm.Hubspot/Controllers/FormsController.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ public async Task<ResponseDto> GetAll()
100100
return new ResponseDto { IsValid = false };
101101
}
102102

103-
var response = await ClientFactory().GetAsync($"{HubspotFormsApiEndpoint}?hapikey=" + hubspotApiKey);
103+
var requestMessage = CreateRequest(hubspotApiKey);
104+
105+
var response = await ClientFactory().SendAsync(requestMessage);
104106

105107
if (response.StatusCode == HttpStatusCode.Unauthorized)
106108
{
@@ -159,12 +161,7 @@ public async Task<ResponseDto> GetAllOAuth()
159161
return new ResponseDto { IsValid = false };
160162
}
161163

162-
var requestMessage = new HttpRequestMessage
163-
{
164-
Method = HttpMethod.Get,
165-
RequestUri = new Uri(HubspotFormsApiEndpoint)
166-
};
167-
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
164+
var requestMessage = CreateRequest(accessToken);
168165

169166
var response = await ClientFactory().SendAsync(requestMessage);
170167
if (response.StatusCode == HttpStatusCode.Unauthorized)
@@ -210,6 +207,17 @@ public async Task<ResponseDto> GetAllOAuth()
210207
return new ResponseDto();
211208
}
212209

210+
private static HttpRequestMessage CreateRequest(string accessToken)
211+
{
212+
var requestMessage = new HttpRequestMessage
213+
{
214+
Method = HttpMethod.Get,
215+
RequestUri = new Uri(HubspotFormsApiEndpoint)
216+
};
217+
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
218+
return requestMessage;
219+
}
220+
213221
[HttpGet]
214222
public HubspotFormPickerSettings CheckConfiguration()
215223
{

0 commit comments

Comments
 (0)