Skip to content

Commit 9a4b097

Browse files
committed
事前に発行したMastodonのclient_id, client_secretの組をApplicetionSettings内に記述する
1 parent b831ed9 commit 9a4b097

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

OpenTween/ApplicationSettings.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,20 @@ internal static class ApplicationSettings
114114
public const string TwitterConsumerKey = "zIoJPq3FsuViPTAs89FetDHYz";
115115
public const string TwitterConsumerSecret = "prTAs2fqLv12nHxlMoLQZT8AkpZt0yYb8A7ktGS2VYeRj0TddS";
116116

117+
//=====================================================================
118+
// Mastodon
119+
120+
/// <summary>
121+
/// Mastodon インスタンス毎に事前に発行した client_id, client_secret の組
122+
/// </summary>
123+
/// <remarks>
124+
/// ここに含まれていないインスタンスでは <see cref="Api.MastodonApi.AppsRegister"/> によって
125+
/// アプリケーションの登録を都度行います
126+
/// </remarks>
127+
public static readonly IReadOnlyDictionary<string, Tuple<string, string>> MastodonClientIds = new Dictionary<string, Tuple<string, string>>
128+
{
129+
};
130+
117131
//=====================================================================
118132
// Foursquare
119133
// https://developer.foursquare.com/ から取得できます。

OpenTween/Mastodon.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ public void Initialize(MastodonCredential account)
5252

5353
public static async Task<MastodonRegisteredApp> RegisterClientAsync(Uri instanceUri)
5454
{
55+
if (ApplicationSettings.MastodonClientIds.TryGetValue(instanceUri.Host, out var client))
56+
{
57+
return new MastodonRegisteredApp
58+
{
59+
ClientId = client.Item1,
60+
ClientSecret = client.Item2,
61+
};
62+
}
63+
5564
using var api = new MastodonApi(instanceUri);
5665
var redirectUri = new Uri("urn:ietf:wg:oauth:2.0:oob");
5766
var scope = "read write follow";

0 commit comments

Comments
 (0)