Skip to content

Commit

Permalink
事前に発行したMastodonのclient_id, client_secretの組をApplicetionSettings内に記述する
Browse files Browse the repository at this point in the history
  • Loading branch information
upsilon committed Mar 6, 2020
1 parent b831ed9 commit 9a4b097
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
14 changes: 14 additions & 0 deletions OpenTween/ApplicationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,20 @@ internal static class ApplicationSettings
public const string TwitterConsumerKey = "zIoJPq3FsuViPTAs89FetDHYz";
public const string TwitterConsumerSecret = "prTAs2fqLv12nHxlMoLQZT8AkpZt0yYb8A7ktGS2VYeRj0TddS";

//=====================================================================
// Mastodon

/// <summary>
/// Mastodon インスタンス毎に事前に発行した client_id, client_secret の組
/// </summary>
/// <remarks>
/// ここに含まれていないインスタンスでは <see cref="Api.MastodonApi.AppsRegister"/> によって
/// アプリケーションの登録を都度行います
/// </remarks>
public static readonly IReadOnlyDictionary<string, Tuple<string, string>> MastodonClientIds = new Dictionary<string, Tuple<string, string>>
{
};

//=====================================================================
// Foursquare
// https://developer.foursquare.com/ から取得できます。
Expand Down
9 changes: 9 additions & 0 deletions OpenTween/Mastodon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ public void Initialize(MastodonCredential account)

public static async Task<MastodonRegisteredApp> RegisterClientAsync(Uri instanceUri)
{
if (ApplicationSettings.MastodonClientIds.TryGetValue(instanceUri.Host, out var client))
{
return new MastodonRegisteredApp
{
ClientId = client.Item1,
ClientSecret = client.Item2,
};
}

using var api = new MastodonApi(instanceUri);
var redirectUri = new Uri("urn:ietf:wg:oauth:2.0:oob");
var scope = "read write follow";
Expand Down

0 comments on commit 9a4b097

Please sign in to comment.