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
oauthClientDiscordOAuth2ClientThe OAuth2 client used to publish the role connection.
callbackResultDiscordOAuthCallbackResultThe completed OAuth callback result.
platformNamestringThe external platform name to show in Discord.
platformUsernamestringThe external platform username to show in Discord.
metadataApplicationRoleConnectionMetadataThe role-connection metadata to publish.
cancellationTokenCancellationTokenA 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, ormetadatais null.- ArgumentException
platformNameorplatformUsernameis empty.- InvalidOperationException
The callback did not succeed or the granted token does not include
role_connections.write.