Skip to content

Commit 1b4959a

Browse files
author
Tiago Brenck
committed
Refactor and new readme
1 parent c334116 commit 1b4959a

File tree

3 files changed

+294
-12
lines changed

3 files changed

+294
-12
lines changed

1-WebApp-OIDC/1-2-AnyOrg/BLL/MSGraphService.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,28 @@ public class MSGraphService : IMSGraphService
2323
/// </returns>
2424
public async Task<IEnumerable<User>> GetUsersAsync(string accessToken)
2525
{
26-
var usersDropDown = new List<SelectListItem>();
27-
26+
IGraphServiceUsersCollectionPage users = null;
27+
2828
try
2929
{
3030
PrepareAuthenticatedClient(accessToken);
31-
IGraphServiceUsersCollectionPage users = await graphServiceClient.Users.Request()
31+
users = await graphServiceClient.Users.Request()
3232
.Filter($"accountEnabled eq true")
3333
.Select("id, userPrincipalName")
3434
.GetAsync();
3535

3636
if (users?.CurrentPage.Count > 0)
3737
{
38-
usersDropDown = users.Select(u => new SelectListItem
39-
{
40-
Text = u.UserPrincipalName,
41-
Value = u.Id
42-
}).ToList();
38+
return users;
4339
}
4440
}
4541
catch (ServiceException e)
4642
{
4743
Debug.WriteLine("We could not retrieve the user's list: " + $"{e}");
4844
return null;
4945
}
50-
51-
return usersDropDown;
46+
47+
return users;
5248
}
5349

5450
/// <summary>

1-WebApp-OIDC/1-2-AnyOrg/Controllers/OnboardingController.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ public IActionResult Onboard()
5353

5454
// Create an OAuth2 request, using the web app as the client.This will trigger a consent flow that will provision the app in the target tenant.
5555
string authorizationRequest = string.Format(
56-
"{0}common/adminconsent?client_id={1}&redirect_uri={2}&state={3}",
56+
"{0}common/v2.0/adminconsent?client_id={1}&redirect_uri={2}&state={3}&scope={4}",
5757
azureADOptions.Instance,
5858
Uri.EscapeDataString(azureADOptions.ClientId),
5959
Uri.EscapeDataString(currentUri + "Onboarding/ProcessCode"),
60-
Uri.EscapeDataString(stateMarker));
60+
Uri.EscapeDataString(stateMarker),
61+
Uri.EscapeDataString("https://graph.microsoft.com/.default"));
6162

6263

6364
return Redirect(authorizationRequest);

0 commit comments

Comments
 (0)