public async Task Authentication(Uri instanceUri, string consumerKey, string consumerSecret) { string url = instanceUri.ToString(); if (string.IsNullOrEmpty(consumerKey)) { var clientKey = await ClientKeyManager.GetMastodonKey(instanceUri.Host); var cachecClientKey = App.Setting.ClientKeys .Where(key => key.Service == ServiceType.Mastodon) .FirstOrDefault(key => string.Equals(key.Host, instanceUri.ToString(), StringComparison.OrdinalIgnoreCase)); if (cachecClientKey == null) { App.Setting.ClientKeys.Add(new ClientKeyCache(instanceUri, clientKey)); consumerKey = clientKey.ClientId; consumerSecret = clientKey.ClientSecret; } else { consumerKey = cachecClientKey.ClientId; consumerSecret = cachecClientKey.ClientSecret; } } this._api = new MastodonApi(instanceUri, consumerKey, consumerSecret); this.AuthorizeUrl = this._api.OAuth.GetAuthorizeUrl(ApiScopes); App.Open(this.AuthorizeUrl); }
public void UpdateApiTokens(MastodonApi api) { this.Api = api; var setting = this._setting; setting.ClientId = api.ApiToken; setting.ClientSecret = api.ApiTokenSecret; setting.AccessToken = api.AccessToken; }
public async Task GetAccessToken(string code) { Uri host = this._api.HostUrl; string consumerKey = this._api.ClientId; string consumerSecret = this._api.ClientSecret; var res = await this._api.OAuth.GetAccessToken(code).ConfigureAwait(false); this._api = new MastodonApi(host, consumerKey, consumerSecret, res.AccessToken); }
public MastodonAccount(MastodonAccountSetting item) : base(false) { this._setting = item.Clone(); this.ItemId = item.ItemId; this.Api = item.CreateApi(); this.InstanceHost = item.InstanceUrl.Host; this.DataStore = new MastodonDataManager(item.InstanceUrl); this.Info = this.DataStore.GetAccount(item); this.Timeline = new MastodonTimeline(this); this.Commands = new AccountCommandGroup(this); ((INotifyPropertyChanged)this.Info).PropertyChanged += this.OnProfileUpdated; }
public MastodonAccount(string itemId, MastodonApi api, Account account) : base(true) { this._setting = new() { ItemId = itemId, InstanceUrl = api.HostUrl, Id = account.Id, }; this.ItemId = itemId; this.Api = api; this.UpdateApiTokens(api); this.InstanceHost = api.HostUrl.Host; this.DataStore = new MastodonDataManager(api.HostUrl); this.Info = this.DataStore.RegisterAccount(account); this.Timeline = new MastodonTimeline(this); this.Commands = new AccountCommandGroup(this); this.OnProfileUpdated(this.Info, new(null)); ((INotifyPropertyChanged)this.Info).PropertyChanged += this.OnProfileUpdated; }
internal InstancesApi(MastodonApi tokens) : base(tokens) { }
internal FollowsApi(MastodonApi tokens) : base(tokens) { }
internal FavouritesApi(MastodonApi tokens) : base(tokens) { }
internal TimelinesApi(MastodonApi tokens) : base(tokens) { }
internal SearchApi(MastodonApi tokens) : base(tokens) { }
internal ListsApi(MastodonApi tokens) : base(tokens) { }
internal StatusesApi(MastodonApi tokens) : base(tokens) { }
public MastodonApiGateway(MastodonAccount account) { this._account = account; this._api = account.Api; }
internal ReportsApi(MastodonApi tokens) : base(tokens) { }
internal FollowRequestsApi(MastodonApi tokens) : base(tokens) { }
internal AccountsApi(MastodonApi tokens) : base(tokens) { }
internal MediaApi(MastodonApi tokens) : base(tokens) { }
internal OAuthApi(MastodonApi tokens) : base(tokens) { this._oauthBaseUrl = new Uri(tokens.HostUrl, "oauth/"); }
public void GetDefaultHttpClient_DoesNotReturnNull() { Assert.NotNull(MastodonApi.GetDefaultHttpClient()); }
internal BlocksApi(MastodonApi tokens) : base(tokens) { }
internal StreamingApi(MastodonApi tokens) : base(tokens) { }