'Invoke-WebRequest : The remote server returned an error: (401) Unauthorized
I can download https://marketplace.visualstudio.com/_apis/gallery/publishers/blueprint/extensions/vsts-open-work-items-in-excel/0.1.71/package?noPrompt=true in my browser. I don't need to be authenticated. it might use a cookie or something.
but the following powershell command raises error (401) Unauthorized.
Invoke-WebRequest -Method Head "https://marketplace.visualstudio.com/_apis/gallery/publishers/blueprint/extensions/vsts-open-work-items-in-excel/0.1.71/package?noPrompt=true"
how can i download it in a powershell script?
I've tried "-credential"
Invoke-WebRequest -Method Head "https://marketplace.visualstudio.com/_apis/gallery/publishers/blueprint/extensions/vsts-open-work-items-in-excel/0.1.71/package?noPrompt=true" -credential "[email protected]"
and
Invoke-WebRequest -Method Head "https://marketplace.visualstudio.com/_apis/gallery/publishers/blueprint/extensions/vsts-open-work-items-in-excel/0.1.71/package?noPrompt=true" -credential "[email protected]"
they ask password but none of them is working. also i tried "-Headers"
$PAT = "blablabla"
$Base64PAT=[Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$PAT"))
$headers = @{ "Authorization" = ('Basic {0}' -f $Base64PAT)}
Invoke-WebRequest -Method Head "https://marketplace.visualstudio.com/_apis/gallery/publishers/blueprint/extensions/vsts-open-work-items-in-excel/0.1.71/package?noPrompt=true" -Headers $headers
I also tried microsoft account's username/password
$securePassword = ConvertTo-SecureString "blablabla" -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist "[email protected]", $securePassword
Invoke-WebRequest -Method Head "https://marketplace.visualstudio.com/_apis/gallery/publishers/blueprint/extensions/vsts-open-work-items-in-excel/0.1.71/package?noPrompt=true" -Credential $cred
Solution 1:[1]
For that link you need authentication. Find another download location without authentication. I tried it in my browser and had to authenticate. I guess your browser authenticates you through cookies.
It would not be a good idea to share that session cookie or store credentials for authentication but it might be possible to do that.
Depending on what you are trying to do Take a look at: https://code.visualstudio.com/docs/editor/extension-marketplace#_workspace-recommended-extensions
The description on that page tells you to use extensions.json File that might be what you really wanted - a preset of recommend plugins
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | An-dir |
