'tf.exe "you are not authorized to access", is not accepting my login parameter

I'm trying to solve this problem since a long time, every execution I perform on TF.exe command, is throwing TF30063 exception, when i'm the admin and the only user of my TFS.

Problem: Try to execute this in a clean machine, without any visual studio user logged in on visual studio, IMPORTANT: also remove your user from windows credentials.

tf.exe workspaces /computer:mycomputer

enter image description here

This modal pops up prompting for credentials, but I need something to be run in a command window without user interference, so checking help I see that you could send /login:user,password

Then, again let's try with that in the command:

tf.exe workspaces /computer:mycomputer /login:[email protected],MyPassword

And now, I get the following exception:

TF30063: You are not authorized to access xxx

BUT, and for the last, if I login on that popup (which I don't want to do because it will be a remote build service) suddenly all commands works fine.

What is the point of having /login command if is not useful here? is there a way to perform this login without prompt?

Thanks for the help!



Solution 1:[1]

It seems you are using VSTS, not on-premises TFS. Usually /login option can be used on on-premises TFS, we use the /login option to specify the Team Foundation Server user account to run a command.

If you want to use on VSTS, you need to get a OAuth token, and specify /loginType:OAuth. The command line is:

tf workspaces /collection:https://xxxx.visualstudio.com /loginType:OAuth /login:.,[OAuth token]

Add a screenshot:

enter image description here

Solution 2:[2]

I know it's been very long since this thread is opened but I recently experienced the same issue and resolved it by following the below steps. This maybe helpful for people who will get stuck with this issue in future...

Yes, I have faced the same issue and was able to resolve the issue finally :)

The problem is that tf.exe command with the switch "/login:username,password" works as expected with the onprem versions, however you have to use OAuth for saas version. Please find the below example command for saas version for your reference.

tf workspaces /collection:https://dev.azure.com/OrganizationName /loginType:OAuth /login:.,OAuthtoken

To generate the OAuth token you should be using the following article as a reference.

https://docs.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/oauth?view=azure-devops

Hope this helps someone at some point of time :)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Vijay reddy sanayapalli