You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Personal Access Token (PAT) serves as an alternative password for authenticating into Azure DevOps. This PAT identifies you and determines your accessibility and scope of access. Treat PATs with the same level of caution as passwords.
21
21
22
-
When you use Microsoft tools, your Microsoft account (MSA) or Microsoft Entra ID is recognized and supported. If you use tools that don't support Microsoft Entra accounts or don't want to share your primary credentials, PATs can be a suitable alternative. However, we recommend using [Microsoft Entra tokens](../../integrate/get-started/authentication/entra.md) over PATs whenever possible.
22
+
When you use Microsoft tools, your Microsoft account (MSA) or Microsoft Entra ID is recognized and supported. If you use tools that don't support Microsoft Entra accounts, or if you prefer not to share your primary credentials, consider using PATs as an alternative authentication method. However, we recommend using [Microsoft Entra tokens](../../integrate/get-started/authentication/entra.md) over PATs whenever possible.
@@ -55,8 +55,8 @@ When you use Microsoft tools, your Microsoft account (MSA) or Microsoft Entra ID
55
55
:::image type="content" source="media/pats/select-pat-scopes-preview.png" alt-text="Screenshot showing selected scopes for a PAT.":::
56
56
57
57
> [!NOTE]
58
-
> Your admin(s) may[restrict you from creating full-scoped PATs or limit you to packaging-scope PATs only](manage-pats-with-policies-for-administrators.md). Reach out to your admin to get on the allowlist if you need access to additional scopes.
59
-
> Some scopes, e.g. `vso.governance`, may not be available in the UI if they aren't for widespread public use.
58
+
> Your administrator might[restrict you from creating full-scoped PATs or limit you to packaging-scope PATs only](manage-pats-with-policies-for-administrators.md). Reach out to your admin to get on the allowlist if you need access to more scopes.
59
+
> Some scopes, for example, `vso.governance`, might not be available in the UI if they aren't for widespread public use.
60
60
61
61
6. When you're done, copy the token and store it in a secure location. For your security, it doesn't display again.
62
62
@@ -66,17 +66,17 @@ Use your PAT anywhere your user credentials are required for authentication in A
66
66
67
67
> [!IMPORTANT]
68
68
> - Treat a PAT with the same caution as your password and keep it confidential. **DO NOT SHARE PATS.**
69
-
> - For organizations backed by Microsoft Entra ID, you must sign in with your new PAT within 90 days or it will become inactive. For more information, see [User sign-in frequency for Conditional Access](/azure/active-directory/conditional-access/howto-conditional-access-session-lifetime).
69
+
> - For organizations backed by Microsoft Entra ID, you must sign in with your new PAT within 90 days or it becomes inactive. For more information, see [User sign-in frequency for Conditional Access](/azure/active-directory/conditional-access/howto-conditional-access-session-lifetime).
70
70
71
71
### Notifications
72
72
73
73
During the lifespan of a PAT, users receive two notifications: at time of creation and three days before expiration.
74
74
75
-
After you create a PAT, you may receive a notification similar to below. This notification serves as confirmation that your PAT was successfully added to your organization.
75
+
After you create a PAT, you might receive a notification similar to the following example. This notification serves as confirmation that your PAT was successfully added to your organization.
76
76
77
77
:::image type="content" source="media/use-personal-access-tokens-to-authenticate/pat-creation.png" alt-text="Screenshot showing PAT created notification.":::
78
78
79
-
An expiration notification email will be sent three days prior to expiration. If your admin has [removed your ability to create PATs in the organization](manage-pats-with-policies-for-administrators.md), the email will indicate that it is no longer possible for you to regenerate PATs. Reach out to your [Project Collection Administrator](../security/look-up-project-collection-administrators.md) to be included in an allowlist for continued PAT creation permissions in that organization.
79
+
An expiration notification email is sent three days before expiration. If your administrator [removed your ability to create PATs in the organization](manage-pats-with-policies-for-administrators.md), the email indicates that it's no longer possible for you to regenerate PATs. Reach out to your [Project Collection Administrator](../security/look-up-project-collection-administrators.md) to be included in an allowlist for continued PAT creation permissions in that organization.
80
80
81
81
::: moniker range=" < azure-devops"
82
82
@@ -103,7 +103,7 @@ If you receive an unexpected PAT notification, it might mean that an administrat
103
103
Your PAT serves as your digital identity, much like a password. You can use PATs as a quick way to do one-off requests or prototype an application locally. Use a PAT in your code to authenticate [REST APIs](/rest/api/azure/devops) requests and automate workflows by including the PAT in the authorization header of your request.
104
104
105
105
> [!IMPORTANT]
106
-
> Once your app code is working, switch to [Microsoft Entra OAuth to acquire tokens on-behalf-of your app's users](../../integrate/get-started/authentication/entra-oauth.md) or a [service principal or managed identity to acquire tokens as an application](../../integrate/get-started/authentication/service-principal-managed-identity.md). It is not recommended to keep running apps or scripts with PATs long-term. Microsoft Entra tokens can be used anywhere a PAT is used.
106
+
> Once your app code is working, switch to [Microsoft Entra OAuth to acquire tokens on-behalf-of your app's users](../../integrate/get-started/authentication/entra-oauth.md) or a [service principal or managed identity to acquire tokens as an application](../../integrate/get-started/authentication/service-principal-managed-identity.md). It isn't recommended to keep running apps or scripts with PATs long-term. Microsoft Entra tokens can be used anywhere a PAT is used.
107
107
> Consider [acquiring a Microsoft Entra token via the Azure CLI](../../cli/entra-tokens.md) for ad-hoc requests.
108
108
109
109
#### [Windows](#tab/Windows/)
@@ -164,25 +164,25 @@ You can revoke a PAT at any time for these and other reasons:
164
164
165
165
## PAT Lifecycle Management APIs
166
166
167
-
The [PAT Lifecycle Management APIs](/rest/api/azure/devops/tokens)may be useful when maintaining large volumes of tokens through UI is unsustainable. Managing PAT rotation programmatically also opens the opportunity to rotate PATs regularly and shorten their default lifespans. Our [sample Python app](https://github.com/microsoft/azure-devops-auth-samples/tree/master/PersonalAccessTokenAPIAppSample) can be configured with your Microsoft Entra tenant and Azure DevOps organization.
167
+
The [PAT Lifecycle Management APIs](/rest/api/azure/devops/tokens)might be useful when maintaining large volumes of tokens through UI is unsustainable. Managing PAT rotation programmatically also opens the opportunity to rotate PATs regularly and shorten their default lifespans. Our [sample Python app](https://github.com/microsoft/azure-devops-auth-samples/tree/master/PersonalAccessTokenAPIAppSample) can be configured with your Microsoft Entra tenant and Azure DevOps organization.
168
168
169
169
Some things to note about these APIs:
170
170
171
171
*[Microsoft Entra access tokens](../../integrate/get-started/authentication/entra.md) are required to access this API as generally a stronger form of authentication is recommended when minting new tokens.
172
172
* Only users or apps using an "on-behalf-of user" flow can generate PATs. Apps using "on-behalf-of application" flows or authentication flows that don't issue Microsoft Entra access tokens aren't valid for use with this API. As such, [service principals or managed identities](../../integrate/get-started/authentication/service-principal-managed-identity.md) can't create or manage PATs.
173
-
* Previously the PAT Lifecycle Management APIs only supported the `user_impersonation` scope, but now the `vso.tokens` are available and the recommended scope to use with these APIS. Downscope all apps that previously relied on `user_impersonation` to call these APIs.
173
+
* Previously the PAT Lifecycle Management APIs only supported the `user_impersonation` scope, but now the `vso.pats` are available and the recommended scope to use with these APIS. Downscope all apps that previously relied on `user_impersonation` to call these APIs.
174
174
175
175
## Changes to format
176
176
177
177
As of July 2024, we updated the format of PAT strings to improve secret detection in our [leaked PAT detection tooling](manage-pats-with-policies-for-administrators.md#revoke-leaked-pats-automatically-tenant-policy) and [partner offerings](../../repos/security/github-advanced-security-secret-scanning.md). This new PAT format includes more identifiable bits to improve the false positive detection rate in these detection tools and mitigate detected leaks faster.
178
178
179
-
* New tokens are now **84** characters long, with 52 characters being randomized data. This improves overall entropy, making tokens more resistant to brute force attacks.
179
+
* New tokens are now **84** characters long, with 52 characters being randomized data, which improves overall entropy, making tokens more resistant to brute force attacks.
180
180
* Tokens issued by our service include a fixed `AZDO` signature at positions 76-80.
181
181
182
-
If you are using a PAT issued prior to that data, regenerate your PAT. If you integrate with PATs and have PAT validation built-in, update your validate code to accommodate both new and existing token lengths.
182
+
If you're using a PAT issued before that data, regenerate your PAT. If you integrate with PATs and have PAT validation builtin, update your validate code to accommodate both new and existing token lengths.
183
183
184
184
> [!WARNING]
185
-
> Both formats will remain valid for the foreseeable future. As adoption of the new format increases, we may retire older 52-character PATs.
185
+
> Both formats remain valid for the foreseeable future. As adoption of the new format increases, we might retire older 52-character PATs.
186
186
187
187
## Best practices for using PATs
188
188
@@ -196,7 +196,7 @@ If you are using a PAT issued prior to that data, regenerate your PAT. If you in
196
196
* Don't put personal data in the PAT name. Don't rename the PAT name to include some or all of the actual PAT token.
197
197
* Avoid creating global PATs unless necessary across all organizations.
198
198
* Use a different token per flow or user case.
199
-
*Choose the minimally needed scopes per PAT. Create a separate PAT with fewer scopes for each flow, instead of a single full-scoped PAT for all flows. If your PAT needs read-only permissions, don't provide write permissions until necessary.
199
+
*Select only the minimum scopes required for each PAT. Grant the least privilege necessary for your specific task, and create separate PATs with limited scopes for different workflows instead of using a single, broad-scoped token. If your PAT needs read-only permissions, don't provide write permissions until necessary.
200
200
* Keep PAT lifespans short (weekly is ideal, even shorter is better).
201
201
202
202
### Managing PATs
@@ -209,13 +209,13 @@ If you are using a PAT issued prior to that data, regenerate your PAT. If you in
209
209
### For admins
210
210
* Tenant admins can set [policies to restrict](manage-pats-with-policies-for-administrators.md) global PAT creation, full scoped PAT creation, and long-lived PAT duration.
211
211
* Tenant admins can [revoke PATs for their organization users](admin-revoke-user-pats.md) if the PAT is compromised.
212
-
* Organization admins can [restrict PAT creation in an organization](manage-pats-with-policies-for-administrators.md). If PATs are still needed, limit their creation to only those on the allowlist.
212
+
* Organization admins can [restrict PAT creation in an organization](manage-pats-with-policies-for-administrators.md). If PATs are still needed, limit their creation to only ones on the allowlist.
213
213
214
214
## FAQs
215
215
216
216
#### Q: Why can't I edit or regenerate a PAT scoped to a single organization?
217
217
218
-
A: Sign into the organization where your PAT is scoped. You can view all your PATs while signed into any organization in the same Microsoft Entra ID by changing the *Access scope* filter, but you can only edit organization-scoped tokens when signed into the specific organization.
218
+
A: Sign into the organization where your PAT is scoped. You can view your PATs when you're signed into any organization in the same Microsoft Entra ID by changing the *Access scope* filter, but you can only edit organization-scoped tokens when signed into the specific organization.
219
219
220
220
#### Q: What happens to a PAT if a user account is disabled?
221
221
@@ -242,7 +242,7 @@ A: PAT authentication requires you to regularly sign into Azure DevOps using the
242
242
Enabling IIS Basic Authentication invalidates using PATs for Azure DevOps Server. We recommend that you keep [IIS Basic Authentication](/iis/configuration/system.webserver/security/authentication/basicauthentication) turned **off** always.
243
243
244
244
> [!WARNING]
245
-
> If you use Git with IIS Basic Authentication, Git breaks because it requires PATs for user authentication. You can adding an extra header to Git requests to use it with IIS Basic Authentication, but this is not recommended. The extra header must be used for all Azure DevOps Server installations, as Windows Auth also prevents using PATs. The extra header must also include a base 64 encoding of "user:PAT."
245
+
> If you use Git with IIS Basic Authentication, Git breaks because it requires PATs for user authentication. You can add an extra header to Git requests to use it with IIS Basic Authentication, but we don't recommend this action. The extra header must be used for all Azure DevOps Server installations, as Windows Auth also prevents using PATs. The extra header must also include a base 64 encoding of `user:PAT`.
@@ -251,21 +251,21 @@ Enabling IIS Basic Authentication invalidates using PATs for Azure DevOps Server
251
251
252
252
A: All PATs are associated with the user identity that created it. Applications can't create PATs.
253
253
254
-
In Azure DevOps, you can create access tokens that aren't tied to a specific person by using Microsoft Entra tokens minted by an [application service principal or managed identity](../../integrate/get-started/authentication/service-principal-managed-identity.md). Within a pipeline, use [service connections](../../pipelines/library/service-endpoints.md).
254
+
In Azure DevOps, you can generate access tokens that aren't linked to a specific user by using Microsoft Entra tokens issued by an [application service principal or managed identity](../../integrate/get-started/authentication/service-principal-managed-identity.md). For pipelines, use [service connections](../../pipelines/library/service-endpoints.md) to securely authenticate and authorize automated tasks without relying on user-specific credentials.
255
255
256
256
### Q: How can I regenerate/rotate PATs through the API? I saw that option in the UI, but I don’t see a similar method in the API.
257
257
The 'Regenerate' functionality available in the UI actually accomplishes a few actions, which can be replicated through API.
258
258
259
259
To rotate your PAT, do the following steps:
260
260
1. See PAT metadata with a **GET** call,
261
-
2. Create a new PAT with the old PAT id using a **POST** call,
261
+
2. Create a new PAT with the old PAT ID using a **POST** call,
262
262
3. Revoke the old PAT using a **DELETE** call.
263
263
264
-
### Q: I see a "Need admin approval" pop-up when I try to use an Entra app to call the PAT Lifecycle Management APIs.
265
-
Your tenant's security policies require admin consent before applications can access organization resources in the organization. Reach out to your tenant admin(s).
264
+
### Q: I see a "Need admin approval" pop-up when I try to use a Microsoft Entra app to call the PAT Lifecycle Management APIs.
265
+
Your tenant's security policies require admin consent before applications can access organization resources in the organization. Reach out to your tenant administrator.
266
266
267
267
### Q: Can I use a service principal to create or manage PATs?
268
-
No, personal access tokens belong to a user identity. Entra [service principals or managed identities](../../integrate/get-started/authentication/service-principal-managed-identity.md) are able to generate short-lived Entra tokens that can be used in most places where a PAT is accepted. Learn more about [our efforts to reduce PAT usage across Azure DevOps](https://devblogs.microsoft.com/devops/reducing-pat-usage-across-azure-devops/) and explore replacing PATs with Entra tokens.
268
+
No, personal access tokens belong to a user identity. Microsoft Entra [service principals or managed identities](../../integrate/get-started/authentication/service-principal-managed-identity.md) are able to generate short-lived Microsoft Entra tokens that can be used in most places where a PAT is accepted. Learn more about [our efforts to reduce PAT usage across Azure DevOps](https://devblogs.microsoft.com/devops/reducing-pat-usage-across-azure-devops/) and explore replacing PATs with Microsoft Entra tokens.
0 commit comments