Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

second round of suggested changes #1098

Merged
merged 2 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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