Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
async Task<string> PasswordFor(string siteName){
var password = string.Empty;
Information($"Retrieving publishing profile for {siteName}...");
using (var client = new HttpClient())
client.BaseAddress = new Uri("");
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {accessToken}");
var content = new StringContent(
var response = await client.PostAsync(
new StringContent(string.Empty));
if (response.IsSuccessStatusCode)
var xml = await response.Content.ReadAsStringAsync();
string pattern = @"userPWD=""(\w)+""";
RegexOptions options = RegexOptions.Multiline;
Match match = Regex.Match(xml, pattern, options);
password = match
.Replace("userPWD=\"", string.Empty)
.Replace("\"", string.Empty);
return password;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment