Created
November 27, 2022 12:15
-
-
Save FreePhoenix888/509a4c744d18427d1c8b67fc29f96dd6 to your computer and use it in GitHub Desktop.
Create nuget token for every available package. Do not forget to select Package Owner to see available packages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get your token by creating one token manually and find it in Browser Developer Tools -> Network -> GenerateApiKey -> Request | |
const REQUEST_VERIFICATION_TOKEN = REQUEST_VERIFICATION_TOKEN; | |
const packages = [ | |
...document | |
.querySelector('.available-packages-container') | |
.querySelectorAll('input'), | |
].map((input) => input.parentNode.textContent.trim()); | |
for (package of packages) { | |
fetch('https://www.nuget.org/account/GenerateApiKey', { | |
headers: { | |
accept: 'application/json, text/javascript, */*; q=0.01', | |
'accept-language': 'en-US,en;q=0.9,ru-RU;q=0.8,ru;q=0.7', | |
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8', | |
'request-context': 'appId=cid-v1:338f6804-b1a9-4fe3-bba7-c93064e7ae7b', | |
'request-id': '|/QVFQ.bTGfN', | |
'sec-ch-ua': | |
'"Google Chrome";v="107", "Chromium";v="107", "Not=A?Brand";v="24"', | |
'sec-ch-ua-mobile': '?0', | |
'sec-ch-ua-platform': '"Linux"', | |
'sec-fetch-dest': 'empty', | |
'sec-fetch-mode': 'cors', | |
'sec-fetch-site': 'same-origin', | |
'x-requested-with': 'XMLHttpRequest', | |
}, | |
referrer: 'https://www.nuget.org/account/apikeys', | |
referrerPolicy: 'strict-origin-when-cross-origin', | |
body: `description=${package}&owner=LinksPlatform&scopes%5B%5D=package%3Apush&subjects%5B%5D=${package}&expirationInDays=365&__RequestVerificationToken=${requestVerificationToken}`, | |
method: 'POST', | |
mode: 'cors', | |
credentials: 'include', | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment