PAT Azure Devops

PAT Azure Devops

By medeb | personalblog | 4 May 2025


1. ERROR The Personal Access Token is mandatory
The error message "ERROR The Personal Access Token is mandatory" means
that you're trying to perform an operation (most likely publishing a VS
Code extension using vsce) that requires authentication with the VS Code
Marketplace, and you haven't provided a Personal Access Token (PAT).
Here's a breakdown of the problem and how to fix it:
Understanding the Error
Authentication:
Publishing extensions to the VS Code Marketplace requires authentication
to verify your identity and permissions.
This authentication is done using a Personal Access Token (PAT).
vsce Requirement:
The vsce (Visual Studio Code Extensions) tool, which is used to package
and publish VS Code extensions, requires a PAT to authenticate with the
marketplace.
Missing PAT:
The error indicates that you're running a vsce command (like vsce
publish) without providing a PAT.
2. How to Fix the Error
Create a Personal Access Token (PAT):
You'll need to create a PAT on Azure DevOps (formerly Visual Studio Team
Services), which is used to manage VS Code Marketplace authentication.
Follow these steps:
Go to your Azure DevOps organization.
Click on your user settings (usually your profile picture) in the top
right corner.
Select "Personal access tokens."
Click "New Token."
Give your token a descriptive name (e.g., "VS Code Extension
Publishing").
Set an expiration date for the token.
Under "Scopes," select "Marketplace (Publish)." This is the crucial step.
Click "Create."
3. Important: Copy the generated PAT immediately and store it securely. You
won't be able to retrieve it later.
Provide the PAT to vsce:
You can provide the PAT to vsce in a few ways:
Environment Variable:
The recommended approach is to set the VSCE_ACCESS_TOKEN environment
variable.
Windows:
Bash
setx VSCE_ACCESS_TOKEN "your-personal-access-token"
After setting the environment variable, close and reopen your terminal.
macOS/Linux:
Bash
export VSCE_ACCESS_TOKEN="your-personal-access-token"
If you want to make this change permanent, add the export command to your
shell's configuration file (e.g., ~/.bashrc, ~/.zshrc).
Command-Line Argument:
You can provide the PAT as a command-line argument using the --pat flag:
Bash
vsce publish --pat "your-personal-access-token"
This is generally less secure than using an environment variable, as the
PAT will be visible in your command history.

5c370356982f0e79f71b09a4b0bf7d3ef3a37990b6c8cfc32c819cf5a3fdb80e.png

How do you rate this article?

3



personalblog
personalblog

My daily experience in crypto world

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.