@@ -20,7 +20,15 @@ public class OAuthProxyController : Controller
20
20
21
21
public const string ServiceNameHeaderKey = "service_name" ;
22
22
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"};
24
32
25
33
public OAuthProxyController ( IHttpClientFactory httpClientFactory , IOptions < AppSettings > appSettings )
26
34
{
@@ -37,7 +45,7 @@ public async Task ProxyTokenRequest()
37
45
serviceName = "Hubspot" ;
38
46
}
39
47
40
- if ( ! ValidServiceNames . Contains ( serviceName ) )
48
+ if ( ! ValidServices . ContainsKey ( serviceName ) )
41
49
{
42
50
throw
43
51
new InvalidOperationException ( $ "Provided { ServiceNameHeaderKey } header value of { serviceName } is not supported") ;
@@ -46,7 +54,7 @@ public async Task ProxyTokenRequest()
46
54
var httpClient = _httpClientFactory . CreateClient ( $ "{ serviceName } Token") ;
47
55
48
56
var response =
49
- await httpClient . PostAsync ( GetAuthUri ( serviceName ) , GetContent ( Request . Form , serviceName ) ) ;
57
+ await httpClient . PostAsync ( ValidServices [ serviceName ] , GetContent ( Request . Form , serviceName ) ) ;
50
58
var content = await response . Content . ReadAsStringAsync ( ) ;
51
59
52
60
Response . StatusCode = ( int ) response . StatusCode ;
@@ -65,7 +73,5 @@ private HttpContent GetContent(IFormCollection form, string serviceName)
65
73
}
66
74
67
75
private string GetClientSecret ( string serviceName ) => _appSettings [ $ "{ serviceName } ClientSecret"] ;
68
-
69
- private string GetAuthUri ( string serviceName ) => _appSettings [ $ "{ serviceName } AuthUri"] ;
70
76
}
71
77
}
0 commit comments