Skip to content

Commit d47d870

Browse files
binnclaude
andcommitted
fix(wrapper): adapt login to CurrentUserLoginResponse and TwoFactorAuthType
Spec 1.21.0 returns CurrentUserLoginResponse from getCurrentUser and types requiresTwoFactorAuth as a list of the TwoFactorAuthType enum. LoginAsync now checks for TwoFactorAuthType.Totp, and LoginWithExternalCodeAsync hands its callback a List<TwoFactorAuthType> instead of strings (breaking change). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 518f070 commit d47d870

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

‎wrapper/VRChat.API/Client/VRChat.cs‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ public interface IVRChat
182182

183183
/// <summary>
184184
/// Logs in as the currently configured user. Will throw an exception unless <b><c>throwOnFail</c></b> is set to <b><c>true</c></b>.
185-
/// <br /> If successful, the <see cref="CurrentUser"/> will be returned, otherwise <b><c>null</c></b> (if <b><c>throwOnFail</c></b> is false).
185+
/// <br /> If successful, the <see cref="CurrentUserLoginResponse"/> will be returned, otherwise <b><c>null</c></b> (if <b><c>throwOnFail</c></b> is false).
186186
/// </summary>
187187
/// <param name="ct">Cancellation token for cancelling any asynchronous operations</param>
188-
/// <returns>A <see cref="Task"/> of <see cref="CurrentUser"/> with the currently logged in user, if successful.</returns>
189-
Task<CurrentUser> LoginAsync(CancellationToken ct = default);
188+
/// <returns>A <see cref="Task"/> of <see cref="CurrentUserLoginResponse"/> with the currently logged in user, if successful.</returns>
189+
Task<CurrentUserLoginResponse> LoginAsync(CancellationToken ct = default);
190190

191191
/// <summary>
192192
/// Authenticates the current user using an external two-factor authentication code provider.
@@ -195,12 +195,12 @@ public interface IVRChat
195195
/// must be obtained from an external source, such as an authenticator app or SMS. The <paramref
196196
/// name="codeAction"/> callback is invoked to prompt the user for the code using the available
197197
/// providers.</remarks>
198-
/// <param name="codeAction">A callback function that receives a list of available two-factor authentication providers and returns an
198+
/// <param name="codeAction">A callback function that receives the <see cref="TwoFactorAuthType"/> methods available for this account and returns an
199199
/// implementation of <see cref="ITwoFactorCode"/> containing the code to use for authentication.</param>
200200
/// <param name="ct">A cancellation token that can be used to cancel the login operation.</param>
201201
/// <returns>A task that represents the asynchronous operation. The task result contains the authenticated <see
202-
/// cref="CurrentUser"/> instance if login succeeds.</returns>
203-
Task<CurrentUser> LoginWithExternalCodeAsync(Func<List<string>, ITwoFactorCode> codeAction, CancellationToken ct = default);
202+
/// cref="CurrentUserLoginResponse"/> instance if login succeeds.</returns>
203+
Task<CurrentUserLoginResponse> LoginWithExternalCodeAsync(Func<List<TwoFactorAuthType>, ITwoFactorCode> codeAction, CancellationToken ct = default);
204204
}
205205

206206
/// <summary>
@@ -362,7 +362,7 @@ public List<Cookie> GetCookies()
362362
/// <inheritdoc/>
363363
public async Task<VRChatLoginResult> TryLoginAsync(CancellationToken ct = default)
364364
{
365-
CurrentUser user = null;
365+
CurrentUserLoginResponse user = null;
366366
try
367367
{
368368
user = await this.LoginAsync(ct);
@@ -383,19 +383,19 @@ public async Task<VRChatLoginResult> TryLoginAsync(CancellationToken ct = defaul
383383
}
384384

385385
/// <inheritdoc/>
386-
public async Task<CurrentUser> LoginAsync(CancellationToken ct = default)
386+
public async Task<CurrentUserLoginResponse> LoginAsync(CancellationToken ct = default)
387387
{
388388
if (_twoFactorSecret == null)
389389
throw new ArgumentNullException("This method only supports logging in with Two-Factor TOTP authentication. Please use VRChatClientBuilder.WithTwoFactorSecret() to use this method");
390390

391-
ApiResponse<CurrentUser> response = await this.Authentication.GetCurrentUserWithHttpInfoAsync(cancellationToken: ct);
391+
ApiResponse<CurrentUserLoginResponse> response = await this.Authentication.GetCurrentUserWithHttpInfoAsync(cancellationToken: ct);
392392

393393
if (response.StatusCode == HttpStatusCode.Unauthorized)
394394
{
395395
throw new UnauthorizedAccessException("401 Unauthorized", new Exception(response.RawContent));
396396
}
397397

398-
if (response.Data.RequiresTwoFactorAuth != null && response.Data.RequiresTwoFactorAuth.Contains("totp"))
398+
if (response.Data.RequiresTwoFactorAuth != null && response.Data.RequiresTwoFactorAuth.Contains(TwoFactorAuthType.Totp))
399399
{
400400
var totp = new Totp(Base32Encoding.ToBytes(_twoFactorSecret));
401401
var twoFactorResponse = await this.Authentication.Verify2FAWithHttpInfoAsync(new TwoFactorAuthCode(totp.ComputeTotp()), ct);
@@ -415,9 +415,9 @@ public async Task<CurrentUser> LoginAsync(CancellationToken ct = default)
415415
}
416416

417417
/// <inheritdoc/>
418-
public async Task<CurrentUser> LoginWithExternalCodeAsync(Func<List<string>, ITwoFactorCode> codeAction, CancellationToken ct = default)
418+
public async Task<CurrentUserLoginResponse> LoginWithExternalCodeAsync(Func<List<TwoFactorAuthType>, ITwoFactorCode> codeAction, CancellationToken ct = default)
419419
{
420-
ApiResponse<CurrentUser> response = await this.Authentication.GetCurrentUserWithHttpInfoAsync(cancellationToken: ct);
420+
ApiResponse<CurrentUserLoginResponse> response = await this.Authentication.GetCurrentUserWithHttpInfoAsync(cancellationToken: ct);
421421

422422
if (response.StatusCode == HttpStatusCode.Unauthorized)
423423
{

0 commit comments

Comments
 (0)