Skip to content

Commit 0e48526

Browse files
committed
Merge remote-tracking branch 'origin/dev' into users/tedchamb/dev
2 parents 2c7f1cd + 2ca5ce0 commit 0e48526

File tree

5 files changed

+38
-17
lines changed

5 files changed

+38
-17
lines changed

README.md

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,54 @@
11
[![Visual Studio Team services](https://mseng.visualstudio.com/_apis/public/build/definitions/698eacea-9ea2-4eb8-80a4-d06170edf6bc/5904/badge)]()
22
[![Python](https://img.shields.io/pypi/pyversions/vsts-cli.svg)](https://pypi.python.org/pypi/vsts)
33

4-
# Microsoft Visual Studio Team Services Python API
4+
# Azure DevOps Python API
55

6-
This repository contains Microsoft Visual Studio Team Services Python API. This API is used to build the Visual Studio Team Services CLI. To learn more about the VSTS CLI, check out our [github repo](https://github.com/Microsoft/vsts-cli).
6+
This repository contains Python APIs for interacting with and managing Azure DevOps. These APIs power the Visual Studio Team Services CLI. To learn more about the VSTS CLI, visit the [Microsoft/vsts-cli](https://github.com/Microsoft/vsts-cli) repo.
77

8-
# Installation
8+
## Install
99

10-
```pip install vsts```
10+
```
11+
pip install vsts
12+
```
1113

12-
# Getting Started
14+
## Get started
1315

14-
Following is an example how to use the API directly:
1516

16-
```
17+
To use the API, establish a connection using a [personal access token](https://docs.microsoft.com/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts) and the URL to your Azure DevOps organization. Then get a client from the connection and make API calls.
18+
19+
```python
1720
from vsts.vss_connection import VssConnection
1821
from msrest.authentication import BasicAuthentication
1922
import pprint
2023

21-
token='REDACTED'
22-
team_instance='https://REDACTED.visualstudio.com'
24+
# Fill in with your personal access token and org URL
25+
personal_access_token = 'YOURPAT'
26+
organization_url = 'https://dev.azure.com/YOURORG'
27+
28+
# Create a connection to the org
29+
credentials = BasicAuthentication('', personal_access_token)
30+
connection = VssConnection(base_url=organization_url, creds=credentials)
2331

24-
credentials = BasicAuthentication('', token)
25-
connection = VssConnection(base_url=team_instance, creds=credentials)
32+
# Get a client (the "core" client provides access to projects, teams, etc)
2633
core_client = connection.get_client('vsts.core.v4_0.core_client.CoreClient')
2734

28-
team_projects = core_client.get_projects()
35+
# Get the list of projects in the org
36+
projects = core_client.get_projects()
2937

30-
for project in team_projects:
38+
# Show details about each project in the console
39+
for project in projects:
3140
pprint.pprint(project.__dict__)
3241
```
3342

34-
# VSTS REST API Documentation
43+
## API documentation
44+
45+
This Python library provides a thin wrapper around the Azure DevOps REST APIs. See the [Azure DevOps REST API reference](https://docs.microsoft.com/en-us/rest/api/vsts/?view=vsts-rest-5.0) for details on calling different APIs.
3546

36-
The python SDK is a thin wrapper around the VSTS REST APIs. Please consult our REST API documentation for API specific details while working with this python SDK.
47+
## Samples
3748

38-
[VSTS REST API Documentation](https://docs.microsoft.com/en-us/rest/api/vsts)
49+
Learn how to call different APIs by viewing the samples in the [Microsoft/azure-devops-python-samples](https://github.com/Microsoft/azure-devops-python-samples) repo.
3950

40-
# Contributing
51+
## Contributing
4152

4253
This project welcomes contributions and suggestions. Most contributions require you to agree to a
4354
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us

vsts/MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include LICENSE.txt

vsts/vsts/git/v4_0/git_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ def get_vsts_info(self, relative_remote_url):
2727
headers = {'Accept': 'application/json'}
2828
if self._suppress_fedauth_redirect:
2929
headers['X-TFS-FedAuthRedirect'] = 'Suppress'
30+
if self._force_msa_pass_through:
31+
headers['X-VSS-ForceMsaPassThrough'] = 'true'
3032
response = self._send_request(request, headers)
3133
return self._deserialize('VstsInfo', response)
3234

vsts/vsts/git/v4_1/git_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ def get_vsts_info(self, relative_remote_url):
2626
headers = {'Accept': 'application/json'}
2727
if self._suppress_fedauth_redirect:
2828
headers['X-TFS-FedAuthRedirect'] = 'Suppress'
29+
if self._force_msa_pass_through:
30+
headers['X-VSS-ForceMsaPassThrough'] = 'true'
2931
response = self._send_request(request, headers)
3032
return self._deserialize('VstsInfo', response)

vsts/vsts/vss_client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def __init__(self, base_url=None, creds=None):
3838
self._all_host_types_locations = None
3939
self._locations = None
4040
self._suppress_fedauth_redirect = True
41+
self._force_msa_pass_through = True
4142
self.normalized_url = VssClient._normalize_url(base_url)
4243

4344
def add_user_agent(self, user_agent):
@@ -88,6 +89,8 @@ def _send(self, http_method, location_id, version, route_values=None,
8889
headers[key] = self.config.additional_headers[key]
8990
if self._suppress_fedauth_redirect:
9091
headers['X-TFS-FedAuthRedirect'] = 'Suppress'
92+
if self._force_msa_pass_through:
93+
headers['X-VSS-ForceMsaPassThrough'] = 'true'
9194
if VssClient._session_header_key in VssClient._session_data and VssClient._session_header_key not in headers:
9295
headers[VssClient._session_header_key] = VssClient._session_data[VssClient._session_header_key]
9396
response = self._send_request(request=request, headers=headers, content=content)
@@ -173,6 +176,8 @@ def _get_resource_locations(self, all_host_types):
173176
headers = {'Accept': 'application/json'}
174177
if self._suppress_fedauth_redirect:
175178
headers['X-TFS-FedAuthRedirect'] = 'Suppress'
179+
if self._force_msa_pass_through:
180+
headers['X-VSS-ForceMsaPassThrough'] = 'true'
176181
response = self._send_request(request, headers=headers)
177182
wrapper = self._base_deserialize('VssJsonCollectionWrapper', response)
178183
if wrapper is None:

0 commit comments

Comments
 (0)