/*AuthenticationContext Context; * * protected async Task<string> GetToken() * { * // The AquireTokenAsync call will prompt with a UI if necessary * // Or otherwise silently use a refresh token to return * // a valid access token * var authenticationResult = await Context.AcquireTokenAsync(Config.ActiveDirectoryBaseUrl, * Config.MediaServicesClientId, * new Uri("http://viime.com"), * new PlatformParameters()); * * return authenticationResult.AccessToken; * }*/ /// <summary> /// Gets the token. /// </summary> /// <returns>The token.</returns> //protected async Task<string> GetToken() protected async Task GetToken() { var url = string.Format("{0}{1}", Config.ActiveDirectoryBaseUrl, Config.ActiveDirectoryTenantId); _activeDirectoryApi = RestService.For <IActiveDirectoryApi>(url, new RefitSettings { JsonSerializerSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() } }); var auth = new AuthBody() { GrantType = "client_credentials", ClientId = Config.MediaServicesClientId, ClientSecret = Config.MediaServicesClientSecret, Resource = Config.MediaServicesResourceUrl }; var result = await _activeDirectoryApi.GetToken(auth); var settings = new SettingsStorable() { BearerToken = result.AccessToken }; await Storage.InsertObject(settings); }
/// <summary> /// Saveds the state. /// </summary> public async Task SavedState() { var storable = new ApplicationStateStorable() { //Key = ApplicationStateHandler.MatchId.ToString(), }; storable.Apply(ApplicationStateHandler); await Storage.InsertObject(storable); }
/// <summary> /// Saveds the state. /// </summary> public async Task SavedState() { NotifyStatusUpdate(); var storable = new ApplicationStateStorable() { //Key = MatchId.ToString(), }; storable.Apply(this); await _storage.InsertObject(storable); }
/// <summary> /// Initializes a new instance of the <see cref="T:FileStorage.Portable.ViewModels.MapPageViewModel"/> class. /// </summary> /// <param name="navigation">Navigation.</param> /// <param name="commandFactory">Command factory.</param> public EditFilePageViewModel(INavigationService navigation, Func <Action, ICommand> commandFactory, IMethods methods, ISQLiteStorage storage) : base(navigation, methods) { _storage = storage; _saveFileCommand = commandFactory(async() => { await _storage.InsertObject(new FileStorable() { Key = FileName, Contents = Contents }); NotifyAlert("File saved."); }); _deleteFileCommand = commandFactory(async() => { await _storage.DeleteObjectByKey <FileStorable>(FileName); await Navigation.Pop(); }); }