A .NET 6 wrapper for Stalcraft's HTTP API. Documentation on the API can be found here: https://eapi.stalcraft.net/.
The Stalcraft API is under active development, and as a result, this api is under active development.
- Implement better testing modules
I'd highly recommend you read through Stalcraft's api documentation, or at the very least read through the OAuth flow. There is a lot of good information in there that won't be included here.
- Setup your application via Stalcraft's telegram service.
- Request authorization from the user. We do this by navigating to an authorization url constructed with the scopes and redirects we need.
string authorizationUrl = string.Empty;
OAuthClient oAuthClient = null;
// Create a new oauth client
oAuthClient = new StalcraftSharp.OAuthClient(<your client id>, <your client secret>, <redirect url>);
// Build an oauth authorization url
authorizationUrl = oAuthClient.GetAuthorizationUrl(OAuthClient.Scopes.Nothing); // At the moment, stalcraft doesn't have any scopes.
- Once the user redirects, if they have allowed the app, the redirect url will have two parameters,
code
andstate
. If those are missing, they likely didn't allow access for our app. Take the code parameter value and request your authorization tokens:
OAuthTokens tokens = null;
// Validate the receipt of the user's token
tokens = await oAuthClient.GetAuthorizationTokensAsync(<code>); // This will return your access token, refresh token, and an expiration time.
And that's it.