diff --git a/src/Microsoft.Identity.Web/Constants/Constants.cs b/src/Microsoft.Identity.Web/Constants/Constants.cs
index e417617ad..377475bb6 100644
--- a/src/Microsoft.Identity.Web/Constants/Constants.cs
+++ b/src/Microsoft.Identity.Web/Constants/Constants.cs
@@ -58,8 +58,13 @@ internal static class Constants
public const string Bearer = "Bearer";
public const string LoginHint = "loginHint";
public const string DomainHint = "domainHint";
+ public const string Authorization = "Authorization";
- // Blazor challenge uri
+ // Blazor challenge URI
public const string BlazorChallengeUri = "MicrosoftIdentity/Account/Challenge?redirectUri=";
+
+ // Microsoft Graph
+ public const string UserReadScope = "user.read";
+ public const string GraphBaseUrlV1 = "https://graph.microsoft.com/v1.0";
}
}
diff --git a/src/Microsoft.Identity.Web/Constants/IDWebErrorMessage.cs b/src/Microsoft.Identity.Web/Constants/IDWebErrorMessage.cs
index 41355123c..5c6eb766f 100644
--- a/src/Microsoft.Identity.Web/Constants/IDWebErrorMessage.cs
+++ b/src/Microsoft.Identity.Web/Constants/IDWebErrorMessage.cs
@@ -31,6 +31,7 @@ internal static class IDWebErrorMessage
public const string UnauthenticatedUser = "IDW10204:The user is unauthenticated. The HttpContext does not contain any claims. ";
public const string BlazorServerBaseUriNotSet = "IDW10205: Using Blazor server but the base URI was not properly set. ";
public const string BlazorServerUserNotSet = "IDW10206: Using Blazor server but the user was not properly set. ";
+ public const string CalledApiScopesAreNull = "IDW10207: The CalledApiScopes cannot be null. ";
// Token Validation IDW10300 = "IDW10300:"
public const string IssuerMetadataUrlIsRequired = "IDW10301: Azure AD Issuer metadata address URL is required. ";
diff --git a/src/Microsoft.Identity.Web/MicrosoftGraph/MicrosoftGraphServiceExtensions.cs b/src/Microsoft.Identity.Web/MicrosoftGraph/MicrosoftGraphServiceExtensions.cs
index af08ebb5c..404c98da4 100644
--- a/src/Microsoft.Identity.Web/MicrosoftGraph/MicrosoftGraphServiceExtensions.cs
+++ b/src/Microsoft.Identity.Web/MicrosoftGraph/MicrosoftGraphServiceExtensions.cs
@@ -10,16 +10,16 @@
namespace Microsoft.Identity.Web
{
///
- /// Extensions methods on a MicrososoftAppCallingWebApiAuthenticationBuilder builder
+ /// Extensions methods on a MicrosoftIdentityAppCallingWebApiAuthenticationBuilder builder
/// to add support to call Microsoft Graph.
///
public static class MicrosoftGraphServiceExtensions
{
///
- /// Add support to calls Microsoft graph. From a named option and a configuration section.
+ /// Add support to call Microsoft Graph. From a named option and a configuration section.
///
/// Builder.
- /// Configuraiton section.
+ /// Configuration section.
/// The builder to chain.
public static MicrosoftIdentityAppCallsWebApiAuthenticationBuilder AddMicrosoftGraphServiceClient(
this MicrosoftIdentityAppCallsWebApiAuthenticationBuilder builder,
@@ -30,16 +30,16 @@ public static MicrosoftIdentityAppCallsWebApiAuthenticationBuilder AddMicrosoftG
}
///
- /// Add support to calls Microsoft graph. From a base graph Url and a default scope.
+ /// Add support to call Microsoft Graph. From a base Graph URL and a default scope.
///
/// Builder.
/// Named instance of option.
- /// Configuraiton section.
+ /// Configuration section.
/// The builder to chain.
public static MicrosoftIdentityAppCallsWebApiAuthenticationBuilder AddMicrosoftGraphServiceClient(
this MicrosoftIdentityAppCallsWebApiAuthenticationBuilder builder,
- string graphBaseUrl = "https://graph.microsoft.com/v1.0",
- string defaultScopes = "user.read")
+ string graphBaseUrl = Constants.GraphBaseUrlV1,
+ string defaultScopes = Constants.UserReadScope)
{
return builder.AddMicrosoftGraphServiceClient(
options =>
@@ -50,7 +50,7 @@ public static MicrosoftIdentityAppCallsWebApiAuthenticationBuilder AddMicrosoftG
}
///
- /// Add support to calls Microsoft graph. From a named options and a configuraiton method.
+ /// Add support to call Microsoft Graph. From a named options and a configuration method.
///
/// Builder.
/// Method to configure the options.
@@ -76,7 +76,7 @@ public static MicrosoftIdentityAppCallsWebApiAuthenticationBuilder AddMicrosoftG
var microsoftGraphOptions = options.Value;
if (microsoftGraphOptions.Scopes == null)
{
- throw new ArgumentException("CalledApiScopes should not be null.");
+ throw new ArgumentException(IDWebErrorMessage.CalledApiScopesAreNull);
}
string graphBaseUrl = microsoftGraphOptions.BaseUrl;
diff --git a/src/Microsoft.Identity.Web/MicrosoftGraph/TokenAcquisitionCredentialProvider.cs b/src/Microsoft.Identity.Web/MicrosoftGraph/TokenAcquisitionCredentialProvider.cs
index 73a8681d0..59e5594bd 100644
--- a/src/Microsoft.Identity.Web/MicrosoftGraph/TokenAcquisitionCredentialProvider.cs
+++ b/src/Microsoft.Identity.Web/MicrosoftGraph/TokenAcquisitionCredentialProvider.cs
@@ -2,6 +2,7 @@
// Licensed under the MIT License.
using System.Collections.Generic;
+using System.Globalization;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Graph;
@@ -30,8 +31,12 @@ public TokenAcquisitionCredentialProvider(ITokenAcquisition tokenAcquisition, IE
public async Task AuthenticateRequestAsync(HttpRequestMessage request)
{
request.Headers.Add(
- "Authorization",
- $"Bearer {await _tokenAcquisition.GetAccessTokenForUserAsync(_initialScopes).ConfigureAwait(false)}");
+ Constants.Authorization,
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "{0}{1}",
+ Constants.Bearer,
+ await _tokenAcquisition.GetAccessTokenForUserAsync(_initialScopes).ConfigureAwait(false)));
}
}
}