예제 #1
0
 public LocationViewModel(INavigation navigation, List <RegionDto> regions)
 {
     Navigation         = navigation;
     _regions           = regions;
     _accountHttpClient = new AccountHttpClient();
     Locations          = null;
     Locations          = new ObservableCollection <LocationListModel>(regions.Select(x => new LocationListModel {
         Region = x.Name
     }));
     _httpClient             = new UniversitiesHttpClient();
     OpenPersonalPageCommand = new Command(async() => await OpenPersonalPageAsync());
 }
예제 #2
0
        public static async Task <AzureDevOpsUserContext> GetUserContext(CancellationToken cancelToken = default)
        {
            const string          aadAuthority   = "https://login.windows.net/microsoft.com";
            const string          aadResource    = "499b84ac-1321-427f-aa17-267ca6975798";
            const string          aadClientId    = "872cd9fa-d31f-45e0-9eab-6e460a02d1f1";
            AuthenticationContext authCtx        = new AuthenticationContext(aadAuthority);
            UserCredential        userCredential = new UserCredential();

            AzureDevOpsUserContext result = new AzureDevOpsUserContext
            {
                AuthenticationResult = await authCtx.AcquireTokenAsync(aadResource, aadClientId, userCredential),
                VssAadCredential     = new VssAadCredential(new VssAadToken(authCtx, userCredential))
            };

            using (VssConnection connection = new VssConnection(new Uri("https://app.vssps.visualstudio.com"), result.VssAadCredential))
            {
                AccountHttpClient accountsClient = await connection.GetClientAsync <AccountHttpClient>(cancelToken);

                result.Accounts = await accountsClient.GetAccountsByMemberAsync(connection.AuthorizedIdentity.Id, cancellationToken : cancelToken);
            }

            return(result);
        }