@@ -12,15 +12,14 @@ namespace Microsoft.Graph.DeveloperProxy.Plugins.RequestLogs;
12
12
13
13
internal enum PermissionsType
14
14
{
15
- [ JsonPropertyName ( "application" ) ]
16
15
Application ,
17
- [ JsonPropertyName ( "delegated" ) ]
18
- DelegatedWork
16
+ Delegated
19
17
}
20
18
21
19
internal class MinimalPermissionsPluginConfiguration
22
20
{
23
- public PermissionsType Type { get ; set ; } = PermissionsType . DelegatedWork ;
21
+ [ JsonPropertyName ( "type" ) ]
22
+ public PermissionsType Type { get ; set ; } = PermissionsType . Delegated ;
24
23
}
25
24
26
25
internal class RequestInfo
@@ -157,13 +156,23 @@ private async void AfterRecordingStop(object? sender, RecordingArgs e)
157
156
await DetermineMinimalScopes ( endpoints ) ;
158
157
}
159
158
159
+ private string GetScopeTypeString ( )
160
+ {
161
+ return _configuration . Type switch
162
+ {
163
+ PermissionsType . Application => "Application" ,
164
+ PermissionsType . Delegated => "DelegatedWork" ,
165
+ _ => throw new InvalidOperationException ( $ "Unknown scope type: { _configuration . Type } ")
166
+ } ;
167
+ }
168
+
160
169
private async Task DetermineMinimalScopes ( IEnumerable < Tuple < string , string > > endpoints )
161
170
{
162
171
var payload = endpoints . Select ( e => new RequestInfo { Method = e . Item1 , Url = e . Item2 } ) ;
163
172
164
173
try
165
174
{
166
- var url = $ "https://graphexplorerapi-staging.azurewebsites.net/permissions?scopeType={ _configuration . Type . ToString ( ) } ";
175
+ var url = $ "https://graphexplorerapi-staging.azurewebsites.net/permissions?scopeType={ GetScopeTypeString ( ) } ";
167
176
using ( var client = new HttpClient ( ) )
168
177
{
169
178
var stringPayload = JsonSerializer . Serialize ( payload ) ;
0 commit comments