Mastodon API Wrapper in C# .NET
Still work in progress, insights and pull requests welcome!
Find it on Nuget
Install-Package Mastodon
As most other mastodon .NET wrappers aren't working anymore, this lib is 100% functionnal for the set of API functionnalities it covers at the date of 09 June 2018.
[WIP]
Register app
using(var appHandler = new AppHandler("InstanceName")){
var scopes = AppScopeEnum.Read | AppScopeEnum.Write | AppScopeEnum.Follow;
var appData = await appHandler.CreateAppAsync("MyAppName", scopes, "ProjectUri");
}
See scope definition
Retrieve OAuth Token per email/password
using(var authHandler = new AuthHandler("InstanceName")){
var tokenInfo = await authHandler.GetTokenInfoAsync("ClientId", "ClientSecret", "UserEmail", "UserPassword", AppScopeEnum.Read);
}
Retrieve OAuth Token per Oauth Code Workflow
using(var authHandler = new AuthHandler("InstanceName")){
var oauthCodeUrl = authHandler.GetOauthCodeUrl("ClientId", AppScopeEnum.Read);
//Open browser/gui to open the oauth url and retrieve the oauth code
var code = GetCodeFromBrowser(oauthCodeUrl);
var tokenInfo = await authHandler.GetTokenInfoAsync("ClientId", "ClientSecret", code);
}
Access API via Client
using(var client = new MastodonClient("InstanceName")){
var timeline = await client.GetHomeTimelineAsync("access_token");
}
See Mastodon API
Nicolas Constant (mastodon)
mastodon.NET is available under the MIT license. See the LICENSE file for more info.