Skip to content

Be able to use with msrest #121

Open

Description

@Sl1ckR1ck

Hi, whenever i try to use this authentification with a package that uses msrest, i get a AttributeError: 'HttpNtlmAuth' object has no attribute 'signed_session'.

It would be nice if it would be supported (and possible?)

Activity

  1. dopstar commented on Feb 27, 2020

    @dopstar

    @Sl1ckR1ck please provide full traceback of the error

  2. Sl1ckR1ck commented on Mar 11, 2020

    @Sl1ckR1ck
    Author

    Hi, sorry for the delay.

    Here is the traceback:

    Traceback (most recent call last):
    File "c:\Users\eric.vscode\extensions\ms-python.python-2020.2.64397\pythonFiles\ptvsd_launcher.py", line 48, in
    main(ptvsdArgs)
    File "c:\Users\eric.vscode\extensions\ms-python.python-2020.2.64397\pythonFiles\lib\python\old_ptvsd\ptvsd_main_.py", line 432, in main
    run()
    File "c:\Users\eric.vscode\extensions\ms-python.python-2020.2.64397\pythonFiles\lib\python\old_ptvsd\ptvsd_main_.py", line 316, in run_file
    runpy.run_path(target, run_name='main')
    File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
    File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
    File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
    File "c:\SESWork\UD\SESScripts\Main\Src\Python\AlmTools\TemplateManager\ReleaseManager_Projects.py", line 328, in
    sys.exit(main(sys.argv[1:]))
    File "c:\SESWork\UD\SESScripts\Main\Src\Python\AlmTools\TemplateManager\ReleaseManager_Projects.py", line 66, in main
    core_client = connection.clients.get_core_client()
    File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\azure\devops\released\client_factory.py", line 44, in get_core_client
    return self._connection.get_client('azure.devops.released.core.core_client.CoreClient')
    File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\azure\devops\connection.py", line 45, in get_client
    self._client_cache[client_type] = self._get_client_instance(client_class)
    File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\azure\devops\connection.py", line 58, in _get_client_instance
    url = self._get_url_for_client_instance(client_class)
    File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\azure\devops\connection.py", line 70, in _get_url_for_client_instance
    resource_areas = self._get_resource_areas()
    File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\azure\devops\connection.py", line 119, in _get_resource_areas
    self._resource_areas = location_client.get_resource_areas()
    File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\azure\devops\v5_0\location\location_client.py", line 107, in get_resource_areas
    query_parameters=query_parameters)
    File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\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 "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\azure\devops\client.py", line 63, in send_request
    content=content, **operation_config)
    File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\msrest\service_client.py", line 336, in send
    pipeline_response = self.config.pipeline.run(request, **kwargs)
    File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\msrest\pipeline_init
    .py", line 197, in run
    return first_node.send(pipeline_request, **kwargs) # type: ignore
    File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\msrest\pipeline_init
    .py", line 150, in send
    response = self.next.send(request, **kwargs)
    File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\msrest\pipeline\requests.py", line 65, in send
    self._creds.signed_session(session)
    AttributeError: 'HttpNtlmAuth' object has no attribute 'signed_session'

  3. dopstar commented on Mar 11, 2020

    @dopstar

    @Sl1ckR1ck can you add code snippet as well

  4. Sl1ckR1ck commented on Mar 11, 2020

    @Sl1ckR1ck
    Author

    Here it is.

    However this will work best if you have a TFS Server available.

    from typing import Sequence
    from typing import List
    
    def main(p_Args:Sequence[str]) -> int:
    	from azure.devops.connection import Connection
    	from msrest.authentication import BasicAuthentication
    	from requests_ntlm import HttpNtlmAuth #type: ignore
    
    	p_UserName = "MyUserName" #change this to your TFS user name.
    	p_UserPassword = "MyTFSPassword"
    
    	#Change this to another TFS collection.
    	TFS_URL = "http://tfsServerTest:8080/tfs/TFSCollection/" 
    
    	credentials=HttpNtlmAuth(p_UserName, p_UserPassword)
    	
    	connection = Connection(base_url=TFS_URL, creds=credentials)
    	
    	#This will fail...
    	core_client = connection.clients.get_core_client()
    
    
    if "__main__" == __name__:
    	import sys
    	sys.dont_write_bytecode = True
    	sys.exit(main(sys.argv[1:]))

    Hopefully this helps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions