Skip to content

Commit 352f82b

Browse files
committed
replaced PAT
1 parent 4b27d8a commit 352f82b

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

docs/integrate/concepts/dotnet-client-libraries.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,21 @@ using Microsoft.VisualStudio.Services.Client;
9999
using Microsoft.TeamFoundation.SourceControl.WebApi;
100100
using Microsoft.VisualStudio.Services.WebApi;
101101

102-
const String c_collectionUri = "https://dev.azure.com/fabrikam";
103-
const String c_projectName = "MyGreatProject";
104-
const String c_repoName = "MyRepo";
102+
const string collectionUri = "https://dev.azure.com/fabrikam";
103+
const string projectName = "MyGreatProject";
104+
const string repoName = "MyRepo";
105+
const string accessToken = "your-microsoft-entra-id-token";
105106

106-
Uri orgUrl = new Uri(c_collectionUri);
107+
Uri orgUrl = new Uri(collectionUri);
107108

108-
// Connect to Azure DevOps Services
109-
VssConnection connection = new VssConnection(orgUrl, new VssBasicCredential(string.Empty, personalAccessToken));
109+
// Connect to Azure DevOps using Microsoft Entra ID token
110+
VssConnection connection = new VssConnection(orgUrl, new VssBasicCredential(string.Empty, accessToken));
110111

111112
// Get a GitHttpClient to talk to the Git endpoints
112113
using (GitHttpClient gitClient = connection.GetClient<GitHttpClient>())
113114
{
114115
// Get data about a specific repository
115-
var repo = gitClient.GetRepositoryAsync(c_projectName, c_repoName).Result;
116+
var repo = gitClient.GetRepositoryAsync(projectName, repoName).Result;
116117
}
117118
```
118119

@@ -131,13 +132,13 @@ namespace ConsoleApp1
131132
const string collectionUri = "https://dev.azure.com/fabrikam";
132133
const string projectName = "MyGreatProject";
133134
const string repoName = "MyRepo";
134-
const string pat = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
135+
const string accessToken = "your-microsoft-entra-id-token";
135136

136137
static void Main(string[] args)
137138
{
138-
var creds = new VssBasicCredential(string.Empty, pat);
139+
var creds = new VssBasicCredential(string.Empty, accessToken);
139140

140-
// Connect to Azure DevOps Services
141+
// Connect to Azure DevOps Services using Microsoft Entra ID token
141142
var connection = new VssConnection(new Uri(collectionUri), creds);
142143

143144
// Get a GitHttpClient to talk to the Git endpoints
@@ -151,6 +152,9 @@ namespace ConsoleApp1
151152

152153
```
153154

155+
> [!TIP]
156+
> **Microsoft Entra ID authentication**: The previous examples use Microsoft Entra ID tokens for authentication. For more information, see [Authenticate to Azure DevOps using Microsoft Entra](../get-started/authentication/entra.md).
157+
154158
For more authentication samples, see [.NET Samples](../get-started/client-libraries/samples.md).
155159

156160
## Reference

0 commit comments

Comments
 (0)