public async Task<AzureToken> LoadToken(string subscriptionId)
{
string path = Path.Combine(_root, "Subscriptions", subscriptionId + ".dat");
if (!File.Exists(path))
{
return null;
}
string content = null;
using (var reader = new StreamReader(path))
{
content = await reader.ReadToEndAsync();
}
if (content == null)
{
return null;
}
var unprotected =
Encoding.UTF8.GetString(
ProtectedData.Unprotect(
Convert.FromBase64String(content),
null,
DataProtectionScope.CurrentUser));
return JsonFormat.Deserialize<AzureToken>(unprotected);
}