Skip to content
Open
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
6 changes: 5 additions & 1 deletion src/NuGetGallery/Controllers/ApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,11 @@ private HttpStatusCodeWithBodyResult GetHttpResultFromFailedApiScopeEvaluationHe
}

string message;
if (result.PermissionsCheckResult == PermissionsCheckResult.Allowed && !result.IsOwnerConfirmed)
if (!result.ScopesAreValid)
{
message = Strings.ApiKeyNotAuthorized_PackageIdScopeMismatch;
}
else if (result.PermissionsCheckResult == PermissionsCheckResult.Allowed && !result.IsOwnerConfirmed)
{
message = Strings.ApiKeyOwnerUnconfirmed;
}
Expand Down
3 changes: 3 additions & 0 deletions src/NuGetGallery/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@
<data name="ApiKeyNotAuthorized" xml:space="preserve">
<value>The specified API key is invalid, has expired, or does not have permission to access the specified package.</value>
</data>
<data name="ApiKeyNotAuthorized_PackageIdScopeMismatch" xml:space="preserve">
<value>The specified API key does not have permission to perform this action on this package. The API key may have a package ID scope that does not include this package ID, or it may not allow the requested action.</value>
</data>
<data name="PackageExistsAndCannotBeModified" xml:space="preserve">
<value>A package with ID '{0}' and version '{1}' already exists and cannot be modified.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public static IEnumerable<object[]> InvalidScopes_Data
{
get
{
yield return MemberDataHelper.AsData(new ApiScopeEvaluationResult(null, PermissionsCheckResult.Unknown, scopesAreValid: false), HttpStatusCode.Forbidden, Strings.ApiKeyNotAuthorized);
yield return MemberDataHelper.AsData(new ApiScopeEvaluationResult(null, PermissionsCheckResult.Unknown, scopesAreValid: false), HttpStatusCode.Forbidden, Strings.ApiKeyNotAuthorized_PackageIdScopeMismatch);

foreach (var result in Enum.GetValues(typeof(PermissionsCheckResult)).Cast<PermissionsCheckResult>())
{
Expand Down