<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Cannot get docker token from server]]></title><description><![CDATA[<p dir="auto">I am having the oddest error.  ProGet returns unauthorized when I try to get a docker token from the server that runs my code.  But it works fine from my Windows PC and from a random container running in OpenShift (from the terminal window).</p>
<p dir="auto">Here is an example of the powershell to get the docker token:</p>
<pre><code>$ProGetRegistry = "acr.mycompany.net"
$FeedName = "myfeed"
$Repo = "runtime/my-container-image"
$ProGetToken = "123456myToken"

$Bytes  = [System.Text.Encoding]::UTF8.GetBytes("api:${ProGetToken}")
$Base64 = [Convert]::ToBase64String($Bytes)

$AuthUrl = "https://${ProGetRegistry}/v2/_auth?service=${ProGetRegistry}&amp;scope=repository:${FeedName}/${Repo}:pull"

$AuthHeaders = @{
         Authorization = "Basic $Base64"
}
$AuthResponse = Invoke-RestMethod -Uri $AuthUrl -Headers $AuthHeaders -Method Get
$AuthResponse.token
</code></pre>
<p dir="auto">Like I said, when I run this on my PC or when I get a terminal to a linux container, it works just fine.  But when I run it on a JAMS Scheduler agent running windows server 2025, ProGet returns:</p>
<pre><code>{
  "errors": [
    {
      "code": "DENIED",
      "message": "requested access to the resource is denied",
      "detail": []
    }
  ]
}
</code></pre>
<p dir="auto">A few other values in the exception that is thrown are:<br />
<strong>Status Code</strong>: 403 (Forbidden)<br />
<strong>Server Name</strong>: Kestrel</p>
<p dir="auto">I have double checked the token I am using and the code (Over and over again.)</p>
<p dir="auto">I am SO confused. Why would ProGet give me the token fine on two locations (my Windows 11 PC and Linux container) and not and not on a Windows Server (2025).</p>
<p dir="auto">Any ideas?</p>
]]></description><link>https://forums.inedo.com/topic/5886/cannot-get-docker-token-from-server</link><generator>RSS for Node</generator><lastBuildDate>Thu, 03 Dec 2026 03:10:40 GMT</lastBuildDate><atom:link href="https://forums.inedo.com/topic/5886.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 03 Dec 2026 00:54:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Cannot get docker token from server on Thu, 03 Dec 2026 01:32:08 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/stephen.schaff" aria-label="Profile: stephen.schaff">@<bdi>stephen.schaff</bdi></a> ,</p>
<p dir="auto">The code "looks" okay to me (similar to that <a href="https://docs.inedo.com/docs/proget/docker/semantic-versioning#retagging-container-images" rel="nofollow ugc">reference script</a> we have), but obviously I didn't or test it.</p>
<p dir="auto">I know you double-checked the token you're using, but that's the only way I can see that <code>403</code> being raised.  I suppose the ProGetRegistry could also be wrong.</p>
<p dir="auto">But according to the code, there are only 4 cases where that <code>403</code> error (i.e. <code>DockerException.Denied()</code>') can occur on the auth handler, and only one of those hit with a Basic <code>api:abc123</code> header.</p>
<p dir="auto">I shared the code below.</p>
<pre><code>private static Task ProcessAuthAsync(AhHttpContext context)
{
    // do not allow the response to be stored on shared caches
    context.Response.AddCacheResponseHeaders(HttpCacheability.Private);

    var authHeader = context.Request.Headers["Authorization"];
    if (string.IsNullOrWhiteSpace(authHeader) || !authHeader.StartsWith("Basic ", StringComparison.OrdinalIgnoreCase))
    {
        if (string.IsNullOrEmpty(context.Request.QueryString["scope"]) || !string.IsNullOrEmpty(context.Request.QueryString["account"]))
        {
            context.Response.AppendHeader("WWW-Authenticate", "basic");
            context.Response.StatusCode = 401;
            return Task.CompletedTask; 
        }

        context.Response.StatusCode = 200;
        context.Response.ContentType = "application/json";

        using var jsonWriter = new JsonTextWriter(context.Response.Output);
        jsonWriter.WriteStartObject();
        jsonWriter.WritePropertyName("token");
        jsonWriter.WriteValue("anonymous");
        jsonWriter.WriteEndObject();

        return Task.CompletedTask;
    }

    var basicAuthToken = InedoLib.UTF8Encoding.GetString(Convert.FromBase64String(authHeader.Substring("Basic ".Length).Trim()));
    var userPass = basicAuthToken.Split(new[] { ':' }, 2);
    if (userPass.Length != 2)
        throw DockerException.Denied();

    string validatedUserToken;
    if (string.Equals(userPass[0], "api", StringComparison.OrdinalIgnoreCase))
    {
        try { WebApiContext.CreateFromKey(context, userPass[1]); }
        catch { throw DockerException.Denied(); }
        
        validatedUserToken = basicAuthToken;
    }
    else
    {
        if (!LicensingInformation.IsFreeEditionEdgeNodeOrInvalid &amp;&amp; !ProGetConfig.Web.UsernamePasswordAuthenticationEnabled)
            throw DockerException.Denied();


        if (WebSecurity.GetUser(userPass[0], userPass[1]) == null)
            throw DockerException.Denied();

        validatedUserToken = userPass[0];
    }

    var ticket = new AhAuthenticationTicket(1, "docker-bearer", DateTime.UtcNow, DateTime.UtcNow.AddHours(1), true, validatedUserToken);
    context.Response.StatusCode = 200;
    context.Response.ContentType = "application/json";
    using (var jsonWriter = new JsonTextWriter(context.Response.Output))
    {
        jsonWriter.WriteStartObject();
        jsonWriter.WritePropertyName("token");
        jsonWriter.WriteValue(AhAuthentication.Encrypt(ticket));
        jsonWriter.WritePropertyName("expires_in");
        jsonWriter.WriteValue((int)(ticket.Expiration - ticket.IssueDate).TotalSeconds);
        jsonWriter.WritePropertyName("issued_at");
        jsonWriter.WriteValue(ticket.IssueDate);
        jsonWriter.WriteEndObject();
    }

    return Task.CompletedTask;
}
</code></pre>
<p dir="auto">Hope that helps. I would try to trigger other error conditions in the code to help preserve your sanity.</p>
<p dir="auto">Thanks,<br />
Alana</p>
]]></description><link>https://forums.inedo.com/post/20260</link><guid isPermaLink="true">https://forums.inedo.com/post/20260</guid><dc:creator><![CDATA[atripp]]></dc:creator><pubDate>Thu, 03 Dec 2026 01:32:08 GMT</pubDate></item></channel></rss>