Skip to content

Commit

Permalink
Set user agent header on auth requests too. (#8562)
Browse files Browse the repository at this point in the history
  • Loading branch information
asherf authored and jsirois committed Nov 4, 2019
1 parent 4cbd854 commit d3214a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/python/pants/auth/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ python_library(
'src/python/pants/process',
'src/python/pants/util:dirutil',
'src/python/pants/util:memo',
'src/python/pants:version',
],
)
3 changes: 2 additions & 1 deletion src/python/pants/auth/basic_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from pants.auth.cookies import Cookies
from pants.subsystem.subsystem import Subsystem
from pants.version import VERSION


@dataclass (frozen=True)
Expand Down Expand Up @@ -84,7 +85,7 @@ def authenticate(self, provider: str, creds: Optional[BasicAuthCreds] = None, co
auth = requests.auth.HTTPBasicAuth(creds.username, creds.password)
else:
auth = None # requests will use the netrc creds.
response = requests.get(url, auth=auth)
response = requests.get(url, auth=auth, headers={'User-Agent': f'pants/v{VERSION}'})

if response.status_code != requests.codes.ok:
if response.status_code == requests.codes.unauthorized:
Expand Down

0 comments on commit d3214a8

Please sign in to comment.