Skip to content

Commit

Permalink
second round of suggested changes (#1098)
Browse files Browse the repository at this point in the history
* second round of suggested changes

* revert one change and pr feedback
  • Loading branch information
jennyf19 authored Mar 29, 2021
1 parent 842170b commit 063f067
Show file tree
Hide file tree
Showing 12 changed files with 321 additions and 288 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public async Task<HttpResponseMessage> CallWebApiForUserAsync(
effectiveOptions.TokenAcquisitionOptions)
.ConfigureAwait(false);

HttpResponseMessage response;
using (HttpRequestMessage httpRequestMessage = new HttpRequestMessage(
effectiveOptions.HttpMethod,
apiUrl))
Expand All @@ -93,10 +92,8 @@ public async Task<HttpResponseMessage> CallWebApiForUserAsync(
httpRequestMessage.Headers.Add(
Constants.Authorization,
authResult.CreateAuthorizationHeader());
response = await _httpClient.SendAsync(httpRequestMessage).ConfigureAwait(false);
return await _httpClient.SendAsync(httpRequestMessage).ConfigureAwait(false);
}

return response;
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Net.Http;

namespace Microsoft.Identity.Web
Expand All @@ -9,7 +10,7 @@ namespace Microsoft.Identity.Web
/// Options passed-in to call downstream web APIs. To call Microsoft Graph, see rather
/// <c>MicrosoftGraphOptions</c> in the <c>Microsoft.Identity.Web.MicrosoftGraph</c> assembly.
/// </summary>
public class DownstreamWebApiOptions
public class DownstreamWebApiOptions : ICloneable
{
/// <summary>
/// Base URL for the called downstream web API. For instance <c>"https://graph.microsoft.com/beta/".</c>.
Expand Down Expand Up @@ -97,5 +98,14 @@ public string[] GetScopes()
{
return string.IsNullOrWhiteSpace(Scopes) ? new string[0] : Scopes.Split(' ');
}

/// <summary>
/// Clone the options (to be able to override them).
/// </summary>
/// <returns>A clone of the options.</returns>
object ICloneable.Clone()
{
return Clone();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public Task<HttpResponseMessage> CallWebApiForUserAsync(
/// <example>
/// A list method that returns an IEnumerable&lt;MyItem&gt;&gt;.
/// <code>
/// public async Task&lt;IEnumerable&lt;MyItem&gt;&gt; GetAsync()
/// public Task&lt;IEnumerable&lt;MyItem&gt;&gt; GetAsync()
/// {
/// return await _downstreamWebApi.CallWebApiForUserAsync&lt;object, IEnumerable&lt;MyItem&gt;&gt;(
/// return _downstreamWebApi.CallWebApiForUserAsync&lt;object, IEnumerable&lt;MyItem&gt;&gt;(
/// ServiceName,
/// null,
/// options =>
Expand All @@ -68,9 +68,9 @@ public Task<HttpResponseMessage> CallWebApiForUserAsync(
///
/// Example of editing.
/// <code>
/// public async Task&lt;MyItem&gt; EditAsync(MyItem myItem)
/// public Task&lt;MyItem&gt; EditAsync(MyItem myItem)
/// {
/// return await _downstreamWebApi.CallWebApiForUserAsync&lt;MyItem, MyItem&gt;(
/// return _downstreamWebApi.CallWebApiForUserAsync&lt;MyItem, MyItem&gt;(
/// ServiceName,
/// nyItem,
/// options =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ public static AuthenticationProperties BuildAuthenticationProperties(
scopes ??= new string[0];
var properties = new AuthenticationProperties();

// Set the scopes, including the scopes that ADAL.NET / MSAL.NET need for the token cache
// Set the scopes, including the scopes that MSAL.NET needs for the token cache
string[] additionalBuiltInScopes =
{
OidcConstants.ScopeOpenId,
OidcConstants.ScopeOfflineAccess,
OidcConstants.ScopeProfile,
};

properties.SetParameter<ICollection<string>>(
OpenIdConnectParameterNames.Scope,
scopes.Union(additionalBuiltInScopes).ToList());
HashSet<string> oidcParams = new HashSet<string>(scopes);
oidcParams.UnionWith(additionalBuiltInScopes);
properties.SetParameter(OpenIdConnectParameterNames.Scope, oidcParams);

// Attempts to set the login_hint to avoid the logged-in user to be presented with an account selection dialog
var loginHint = user.GetLoginHint();
Expand Down
42 changes: 24 additions & 18 deletions src/Microsoft.Identity.Web/Microsoft.Identity.Web.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 063f067

Please sign in to comment.