@@ -20,7 +20,15 @@ public class OAuthProxyController : Controller
2020
2121 public const string ServiceNameHeaderKey = "service_name" ;
2222
23- private static List < string > ValidServiceNames = new List < string > { "Hubspot" , "Semrush" } ;
23+ /// <summary>
24+ /// Integrated services with their token URIs
25+ /// </summary>
26+ private static Dictionary < string , string > ValidServices = new Dictionary < string , string >
27+ {
28+ { "Hubspot" , "oauth/v1/token" } , { "Semrush" , "oauth2/access_token" }
29+ } ;
30+
31+ //private static List<string> ValidServiceNames = new List<string> {"Hubspot", "Semrush"};
2432
2533 public OAuthProxyController ( IHttpClientFactory httpClientFactory , IOptions < AppSettings > appSettings )
2634 {
@@ -37,7 +45,7 @@ public async Task ProxyTokenRequest()
3745 serviceName = "Hubspot" ;
3846 }
3947
40- if ( ! ValidServiceNames . Contains ( serviceName ) )
48+ if ( ! ValidServices . ContainsKey ( serviceName ) )
4149 {
4250 throw
4351 new InvalidOperationException ( $ "Provided { ServiceNameHeaderKey } header value of { serviceName } is not supported") ;
@@ -46,7 +54,7 @@ public async Task ProxyTokenRequest()
4654 var httpClient = _httpClientFactory . CreateClient ( $ "{ serviceName } Token") ;
4755
4856 var response =
49- await httpClient . PostAsync ( GetAuthUri ( serviceName ) , GetContent ( Request . Form , serviceName ) ) ;
57+ await httpClient . PostAsync ( ValidServices [ serviceName ] , GetContent ( Request . Form , serviceName ) ) ;
5058 var content = await response . Content . ReadAsStringAsync ( ) ;
5159
5260 Response . StatusCode = ( int ) response . StatusCode ;
@@ -65,7 +73,5 @@ private HttpContent GetContent(IFormCollection form, string serviceName)
6573 }
6674
6775 private string GetClientSecret ( string serviceName ) => _appSettings [ $ "{ serviceName } ClientSecret"] ;
68-
69- private string GetAuthUri ( string serviceName ) => _appSettings [ $ "{ serviceName } AuthUri"] ;
7076 }
7177}
0 commit comments