Table of Contents

Class DiscordOAuth2Client

Namespace
DisCatSharp
Assembly
DisCatSharp.dll

Represents a DiscordOAuth2Client.

public sealed class DiscordOAuth2Client : IDisposable
Inheritance
DiscordOAuth2Client
Implements
Inherited Members

Constructors

DiscordOAuth2Client(ulong, string, string, IServiceProvider, IWebProxy, TimeSpan?, bool, ILoggerFactory, LogLevel, string)

Creates a new OAuth2 client.

Fields

ClientId

Gets the client id.

ClientSecret

Gets the client secret.

RedirectUri

Gets the redirect uri.

VersionHeader

Gets the string representing the version header of the bot lib.

Properties

BotLibrary

Gets the bot library name.

Logger

Gets the logger for this client.

ServiceProvider

Gets the service provider this OAuth2 client was configured with.

Methods

AddCurrentUserToGuildAsync(DiscordAccessToken, ulong, string?, IEnumerable<DiscordRole>?, bool?, bool?)

Adds the current user to the given guildId.

Some parameters might need additional permissions for the bot on the target guild. See https://discord.com/developers/docs/resources/guild#add-guild-member for details.

This methods invokes a sub-request to GetCurrentUserAsync(DiscordAccessToken).

AddCurrentUserToGuildAsync(DiscordAccessToken, ulong, ulong, string?, IEnumerable<DiscordRole>?, bool?, bool?)

Adds the given userId to the given guildId.

Some parameters might need additional permissions for the bot on the target guild. See https://discord.com/developers/docs/resources/guild#add-guild-member for details.

This methods does not invoke a sub-request to GetCurrentUserAsync(DiscordAccessToken).

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

ExchangeAccessTokenAsync(string)

Exchanges a code for an discord access token.

~DiscordOAuth2Client()
GenerateOAuth2Url(string, string, bool)

Generates an OAuth2 url.

GenerateSecureState(ulong)

Generates a secured state bound to the user id.

If the bot is completely restarted, such a state can't be decrypted anymore.

To decrypt this state, use ReadSecureState(string)

GenerateState()

Generates a state for OAuth2 authorization.

GetCodeFromUri(Uri)

Gets the OAuth2 code to use with ExchangeAccessTokenAsync(string) from the url.

GetCurrentAuthorizationInformationAsync(DiscordAccessToken)

Gets the current authorization information.

GetCurrentUserApplicationRoleConnectionAsync(DiscordAccessToken)

Gets the current user's application role connection.

GetCurrentUserAsync(DiscordAccessToken)

Gets the current user.

GetCurrentUserConnectionsAsync(DiscordAccessToken)

Gets the current user's connections.

GetCurrentUserGuildMemberAsync(DiscordAccessToken, ulong)

Gets the current user's guild member for given guildId.

GetCurrentUserGuildsAsync(DiscordAccessToken)

Gets the current user's guilds.

GetStateFromUri(Uri)

Gets the OAuth2 code to use with ExchangeAccessTokenAsync(string) from the url.

ReadSecureState(string)

Reads a secured state generated from GenerateSecureState(ulong).

If the bot is completely restarted, such a state can't be decrypted anymore.

RefreshAccessTokenAsync(DiscordAccessToken)

Exchanges a refresh token for a new discord access token.

RevokeByAccessTokenAsync(DiscordAccessToken)

Revokes an OAuth2 token via its access token.

RevokeByRefreshTokenAsync(DiscordAccessToken)

Revokes an OAuth2 token via its refresh token.

UpdateCurrentUserApplicationRoleConnectionAsync(DiscordAccessToken, string, string, ApplicationRoleConnectionMetadata)

Updates the current user's application role connection.

ValidateState(Uri, Uri, bool)

Validates the OAuth2 state.

Events

OAuth2ClientErrored

Fired whenever an error occurs within an event handler.