devopshq / teamcity

dohq-teamcity is a Python package providing access to the JetBrains TeamCity server API.
https://devopshq.github.io/teamcity/
MIT License
33 stars 12 forks source link

Can't find a way to authenticate using token vs username/password #23

Open droopy4096 opened 4 years ago

droopy4096 commented 4 years ago

I've tried several ways of using auth token:

tc=TeamCity('https://tc.my.com',auth=tc_token) 

and

tc.set_default_header(header_name='Authorization', header_value='Bearer {token}'.format(token=tc_token)) 

all unsuccessful with HTTP 404 error. HTTP response body: Invalid authentication request or authentication scheme is not supported

allburov commented 4 years ago

@vasokot could you please test the above example with our teamcity instance?

allburov commented 4 years ago

@droopy4096 Does it work with user password pair? If answer is yes you probably should try use auth=(username, token), i.e. change your password to your token.

j-krauz commented 4 years ago

Hi, I have the same problem. I can't use user+password pair since our Teamcity server is linked to a SAML Identity Provider and the basic authentication is disabled. The only option is authentication tokens.

I tried a few things but couldn't make it work. I noticed there are token-related variables in the Configuration class so I tried the following

config = Configuration()
config.api_key = {'test': '<token>'}
config.api_key_prefix = {'test': 'Bearer'}
tc = TeamCity("<teamcity-url>", auth=None, configuration=config)

but still no luck.

allburov commented 4 years ago

@vasokot could one of our DevOps-team look at the issue?

martwana commented 3 years ago

Unsure if this is still active, but I've fixed this in https://github.com/devopshq/teamcity/pull/29