Skip to content

Commit 3901fca

Browse files
Merge pull request #8212 from MicrosoftDocs/artifacts/478816
PAT base64
2 parents 4416f73 + a66185c commit 3901fca

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

docs/artifacts/includes/npm/npmrc.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ ms.date: 09/11/2023
7272
node -e "require('readline') .createInterface({input:process.stdin,output:process.stdout,historySize:0}) .question('PAT> ',p => { b64=Buffer.from(p.trim()).toString('base64');console.log(b64);process.exit(); })"
7373
```
7474
75+
> [!NOTE]
76+
> As of July 2024, Azure DevOps Personal Access Tokens (PATs) are [82 characters long](../../../organizations/accounts/use-personal-access-tokens-to-authenticate.md#changes-to-format). Some tools may insert automatic line breaks when encoding tokens to Base64. To avoid this, use the `-w0` flag with the *base64* command to ensure the output stays on a single line.
77+
> In this tutorial, we use Node’s Buffer method, which produces a single-line *Base64* string by default.
78+
7579
1. Open your `.npmrc` file and replace the placeholder `[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]` with your encoded personal access token you just created.
7680
7781
::: moniker-end

docs/artifacts/npm/npmrc.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ monikerRange: '>= azure-devops-2020'
1414

1515
[!INCLUDE [version-gt-eq-2020](../../includes/version-gt-eq-2020.md)]
1616

17-
Azure Artifacts enables developers to manage packages from various sources, including public registries like *npmjs.com* and private feeds. To authenticate with Azure Artifacts, you need to configure your *.npmrc* config file. This file stores feed URLs and credentials used by npm, and it allows you to customize client behavior such as setting up proxies, defining default package locations, or configuring access to private feeds. The *.npmrc* file is typically located in the user's home directory, but can also be created at the project level to override default settings.
17+
Azure Artifacts enables developers to manage packages from various sources, including public registries like *npmjs.com* and private feeds. To authenticate with Azure Artifacts, you need to configure your *npmrc* config file. This file stores feed URLs and credentials used by npm, and it allows you to customize client behavior such as setting up proxies, defining default package locations, or configuring access to private feeds. The *npmrc* file is typically located in the user's home directory, but can also be created at the project level to override default settings.
1818

1919
## Prerequisites
2020

@@ -113,13 +113,17 @@ The following steps guide you through setting up the project-level configuration
113113
node -e "require('readline') .createInterface({input:process.stdin,output:process.stdout,historySize:0}) .question('PAT> ',p => { b64=Buffer.from(p.trim()).toString('base64');console.log(b64);process.exit(); })"
114114
```
115115
116+
> [!NOTE]
117+
> As of July 2024, Azure DevOps Personal Access Tokens (PATs) are [82 characters long](../../organizations/accounts/use-personal-access-tokens-to-authenticate.md#changes-to-format). Some tools may insert automatic line breaks when encoding tokens to Base64. To avoid this, use the `-w0` flag with the *base64* command to ensure the output stays on a single line.
118+
> In this tutorial, we use Node’s Buffer method, which produces a single-line *Base64* string by default.
119+
116120
1. If you're using Linux or macOS, you can run the following command in your terminal to convert your personal access token (PAT) to a Base64-encoded string. Copy the resulting value to use in the next step.
117121
118122
```
119-
echo -n "YOUR_PERSONAL_ACCESS-TOKEN" | base64
123+
echo -n "YOUR_PERSONAL_ACCESS-TOKEN" | base64 -w0
120124
```
121125
122-
1. Replace the placeholders *[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]* in your user-level *.npmrc* file with the Base64-encoded personal access token you generated in the previous step.
126+
1. Replace the placeholders *[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]* in your user-level *npmrc* file with the Base64-encoded personal access token you generated in the previous step.
123127
124128
* * *
125129
@@ -135,7 +139,7 @@ The following steps guide you through setting up the project-level configuration
135139
136140
:::image type="content" source="../media/server-2022-1-connect-to-feed.png" alt-text="A screenshot showing how to connect to a feed in Azure DevOps Server 2022.1.":::
137141
138-
1. Select **npm** from the left, and then follow the steps in the **Project setup** section to configure your .npmrc. file and authenticate with your feed.
142+
1. Select **npm** from the left, and then follow the steps in the **Project setup** section to configure your *npmrc* file and authenticate with your feed.
139143
140144
:::image type="content" source="../media/npm-project-setup-server-2022-1.png" alt-text="A screenshot showing how to set up your npm project in Azure DevOps Server 2022.1.":::
141145
@@ -147,7 +151,7 @@ The following steps guide you through setting up the project-level configuration
147151
148152
1. Select **Connect to Feed** and then select **npm** from the left navigation pane.
149153
150-
1. Add a *.npmrc* file in your project's directory, in the same directory as your *package.json* file, and paste the snippet provided in the **Project setup** section into your *.npmrc* file. Your file should look similar to the following:
154+
1. Add a *.npmrc* file in your project's directory, in the same directory as your *package.json* file, and paste the snippet provided in the **Project setup** section into your *npmrc* file. Your file should look similar to the following:
151155
152156
```
153157
registry=http://<SERVER_NAME>/<COLLECTION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/npm/registry/
@@ -193,6 +197,10 @@ The following steps guide you through setting up the project-level configuration
193197
node -e "require('readline') .createInterface({input:process.stdin,output:process.stdout,historySize:0}) .question('PAT> ',p => { b64=Buffer.from(p.trim()).toString('base64');console.log(b64);process.exit(); })"
194198
```
195199
200+
> [!NOTE]
201+
> As of July 2024, Azure DevOps Personal Access Tokens (PATs) are [82 characters long](../../organizations/accounts/use-personal-access-tokens-to-authenticate.md#changes-to-format). Some tools may insert automatic line breaks when encoding tokens to Base64. To avoid this, use the `-w0` flag with the *base64* command to ensure the output stays on a single line.
202+
> In this tutorial, we use Node’s Buffer method, which produces a single-line *Base64* string by default.
203+
196204
1. Replace the placeholders *[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]* in your user-level *.npmrc* file with the Base64-encoded personal access token you generated in the previous step.
197205
198206
* * *
@@ -221,7 +229,7 @@ The following steps guide you through setting up the project-level configuration
221229
222230
1. Select **Connect to Feed** and then select **npm** from the left navigation pane.
223231
224-
1. Add a *.npmrc* file in your project's directory, in the same directory as your *package.json* file, and paste the snippet provided in the **Project setup** section into your *.npmrc* file. Your file should look similar to the following:
232+
1. Add a *.npmrc* file in your project's directory, in the same directory as your *package.json* file, and paste the snippet provided in the **Project setup** section into your *npmrc* file. Your file should look similar to the following:
225233
226234
```
227235
registry=http://<SERVER_NAME>/<COLLECTION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/npm/registry/
@@ -270,6 +278,10 @@ The following steps guide you through setting up the project-level configuration
270278
node -e "require('readline') .createInterface({input:process.stdin,output:process.stdout,historySize:0}) .question('PAT> ',p => { b64=Buffer.from(p.trim()).toString('base64');console.log(b64);process.exit(); })"
271279
```
272280
281+
> [!NOTE]
282+
> As of July 2024, Azure DevOps Personal Access Tokens (PATs) are [82 characters long](../../organizations/accounts/use-personal-access-tokens-to-authenticate.md#changes-to-format). Some tools may insert automatic line breaks when encoding tokens to Base64. To avoid this, use the `-w0` flag with the *base64* command to ensure the output stays on a single line.
283+
> In this tutorial, we use Node’s Buffer method, which produces a single-line *Base64* string by default.
284+
273285
1. Replace the placeholders *[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]* in your user-level *.npmrc* file with the Base64-encoded personal access token you generated in the previous step.
274286
275287
* * *

0 commit comments

Comments
 (0)