microsoft / microsoft/azure-devops-auth-samples

VssBasicCredential with PAT not working on Windows Service

Open
#77 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
277
Forks
307
Avg merge
3d 18h
Merged PRs (30d)
2

Description

I'm building a Windows Service project running .netcore3.1 that extracts some backlog items.
Running on VisualStudio (debug and release mode) works fine.

After deploying, and installing the service using SC CREATE I've got the message: "Microsoft.VisualStudio.Services.Common.VssUnauthorizedException: TF400813: The user 'MyDomain\MyComputer$' is not authorized to access this resource."

But I'm using the same PAT and the same URL.

Here is the code that I'm using:

var creds = new VssBasicCredential(string.Empty, "My PAT");
var collectionUrl = new Uri("The collection URL");
var connection = new VssConnection(collectionUrl, creds);
var witClient = await connection.GetClientAsync<WorkItemTrackingHttpClient>();

The exception is thrown when connection.GetClientAsync is called.

Any ideas on why it is working running on Visual Studio but not as a Windows Service?

Thanks

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the connection.GetClientAsync() call and compare the identity and credential context when the code runs in Visual Studio versus the installed Windows Service. Done means isolating why the PAT request is evaluated as MyDomain\MyComputer$ and documenting or implementing a verified resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
authentication, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.