Table of Contents
API reference

Method PublishRoleConnectionAsync

Namespace
DisCatSharp.Hosting.AspNetCore.LinkedRoles
Assembly
DisCatSharp.Hosting.AspNetCore.dll

PublishRoleConnectionAsync(DiscordOAuth2Client, DiscordOAuthCallbackResult, string, string, ApplicationRoleConnectionMetadata, CancellationToken)

Publishes a linked-roles connection update using the access token captured by a successful OAuth callback.

public Task<DiscordApplicationRoleConnection> PublishRoleConnectionAsync(DiscordOAuth2Client oauthClient, DiscordOAuthCallbackResult callbackResult, string platformName, string platformUsername, ApplicationRoleConnectionMetadata metadata, CancellationToken cancellationToken = default)

Parameters

oauthClient DiscordOAuth2Client

The OAuth2 client used to publish the role connection.

callbackResult DiscordOAuthCallbackResult

The completed OAuth callback result.

platformName string

The external platform name to show in Discord.

platformUsername string

The external platform username to show in Discord.

metadata ApplicationRoleConnectionMetadata

The role-connection metadata to publish.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<DiscordApplicationRoleConnection>

The updated application role connection.

Remarks

This helper is intended for the final step of the OAuth callback flow after the callback result has been validated and the access token has been confirmed to include role_connections.write.

Exceptions

ArgumentNullException

oauthClient, callbackResult, or metadata is null.

ArgumentException

platformName or platformUsername is empty.

InvalidOperationException

The callback did not succeed or the granted token does not include role_connections.write.