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

VssBasicCredential with PAT not working on Windows Service #77

Open
LuigiMaestrelli opened this issue Apr 26, 2021 · 2 comments
Open

VssBasicCredential with PAT not working on Windows Service #77

LuigiMaestrelli opened this issue Apr 26, 2021 · 2 comments

Comments

@LuigiMaestrelli
Copy link

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

@lucasmartins098
Copy link

i am the same problem

@lucasmartins098
Copy link

Solved, now to work you need to insert this code before the connection:

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants