Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
private async Task GetSubscriptions(string tenantId)
{
var requestUrl = "https://management.azure.com/subscriptions?api-version=2015-01-01";
try {
var data = await DependencyService.Get<IAuthenticator> ().AuthenticateSilently (tenantId,
App.ManagementResourceUri, App.ClientId);
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", data.AccessToken);
var subsriptionResponse = await client.GetStringAsync (requestUrl);
var subscriptions = JsonConvert.DeserializeObject<SubscriptionResponse>(subsriptionResponse);
foreach (var subscription in subscriptions.SubscriptionCollection) {
SubscriptionCollection.Add(subscription); }
IsFirstRunComplete = true; }
catch (Exception ex) {
await DisplayAlert("Error!", ex.Message, "Dismiss"); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.