azure-devops-python-api icon indicating copy to clipboard operation
azure-devops-python-api copied to clipboard

BasicAuthentication doesn't work with login and password

Open asapelkin opened this issue 3 years ago • 0 comments

Hi! We have a special case in our system where we can't use the token. We tried using BasicAuthentication with a user and password and were not successful.

Our code

from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication

organization_url = 'https://tfs.my/tfs/DefaultCollection/'
credentials = BasicAuthentication("user", "password")

connection = Connection(base_url=organization_url, creds=credentials)
connection.authenticate() 

Our result.

Traceback (most recent call last):
  File "/home/asapelkin/projs/ms_api_test/main.py", line 55, in <module>
    connection.authenticate()
  File "/home/asapelkin/projs/venv/lib/python3.7/site-packages/azure/devops/connection.py", line 102, in authenticate
    self._get_resource_areas(force=True)
  File "/home/asapelkin/projs/venv/lib/python3.7/site-packages/azure/devops/connection.py", line 120, in _get_resource_areas
    self._resource_areas = location_client.get_resource_areas()
  File "/home/asapelkin/projs/venv/lib/python3.7/site-packages/azure/devops/v5_1/location/location_client.py", line 107, in get_resource_areas
    query_parameters=query_parameters)
  File "/home/asapelkin/projs/venv/lib/python3.7/site-packages/azure/devops/client.py", line 104, in _send
    response = self._send_request(request=request, headers=headers, content=content, media_type=media_type)
  File "/home/asapelkin/projs/venv/lib/python3.7/site-packages/azure/devops/client.py", line 68, in _send_request
    self._handle_error(request, response)
  File "/home/asapelkin/projs/venv/lib/python3.7/site-packages/azure/devops/client.py", line 270, in _handle_error
    raise AzureDevOpsServiceError(wrapped_exception)
azure.devops.exceptions.AzureDevOpsServiceError: TF400813: Resource not available for anonymous access. Client authentication required.

Login and password are working, checked through the tfs api and curl.

asapelkin avatar Feb 16 '21 12:02 asapelkin