onlivfe/vrc_rs

Error: An error happened with serialization: GetCurrentUser

ShayBox opened this issue · 1 comments

I tried to run the following code, but I get Error: An error happened with serialization

use once_cell::sync::Lazy;
use vrc::{
    api_client::{ApiClient, AuthenticatedVRC},
    model::CurrentAccount,
    query::{Authentication, GetCurrentUser},
};

static USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
static USER_AUTH: Lazy<Authentication> = Lazy::new(|| {
    let bytes = std::fs::read("user-auth.json")
        .expect("must have a prepared `user-auth.json` file for live API testing");

    let user_auth = serde_json::from_slice::<Authentication>(&bytes)
        .expect("`user-auth.json` file to parse into user auth");

    assert!(!user_auth.token.is_empty());
    assert!(user_auth.token.len() > 20);

    user_auth
});

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let vrc = AuthenticatedVRC::new(USER_AGENT.to_owned(), USER_AUTH.clone())?;
    let current_user: CurrentAccount = vrc.query(GetCurrentUser).await?;

    dbg!(&current_user);

    Ok(())
}

Here's the debug printed JSON un-stringified, beautified, and redacted for comparison.
Anything redacted was replaced with ... except for the steam time created was replaced with 0.

{
  "id": "...",
  "displayName": "...",
  "userIcon": "",
  "bio": "...",
  "bioLinks": [
    "..."
  ],
  "profilePicOverride": "",
  "statusDescription": "...",
  "username": "...",
  "pastDisplayNames": [
    {
      "displayName": "...",
      "updated_at": "...",
      "reverted": false
    }
  ],
  "hasEmail": true,
  "hasPendingEmail": false,
  "obfuscatedEmail": "...",
  "obfuscatedPendingEmail": "",
  "emailVerified": true,
  "hasBirthday": true,
  "hideContentFilterSettings": false,
  "unsubscribe": true,
  "statusHistory": [
    "..."
  ],
  "statusFirstTime": false,
  "friends": [
    "..."
  ],
  "friendGroupNames": [],
  "queuedInstance": null,
  "userLanguage": "English",
  "userLanguageCode": "en",
  "currentAvatarImageUrl": "...",
  "currentAvatarThumbnailImageUrl": "...",
  "currentAvatarTags": [],
  "currentAvatar": "...",
  "currentAvatarAssetUrl": "...",
  "fallbackAvatar": "...",
  "accountDeletionDate": null,
  "accountDeletionLog": null,
  "acceptedTOSVersion": 9,
  "acceptedPrivacyVersion": 1,
  "steamId": "...",
  "googleId": "",
  "steamDetails": {
    "avatar": "...",
    "avatarfull": "...",
    "avatarhash": "...",
    "avatarmedium": "...",
    "commentpermission": 2,
    "communityvisibilitystate": 3,
    "personaname": "...",
    "personastate": 0,
    "profilestate": 1,
    "profileurl": "...",
    "steamid": "...",
    "personastateflags": 0,
    "primaryclanid": "...",
    "timecreated": 0
  },
  "oculusId": "",
  "picoId": "",
  "viveId": "",
  "hasLoggedInFromClient": false,
  "homeLocation": "wrld_f3d1f874-0e3f-4f35-bb28-10c6991fe4a4",
  "twoFactorAuthEnabled": false,
  "twoFactorAuthEnabledDate": null,
  "updated_at": "2024-01-15T03:21:10.932Z",
  "state": "offline",
  "tags": [
    "system_no_captcha",
    "language_eng",
    "system_world_access",
    "system_avatar_access",
    "system_trust_basic",
    "system_feedback_access",
    "system_early_adopter",
    "system_trust_known",
    "system_trust_trusted",
    "system_trust_veteran"
  ],
  "developerType": "none",
  "last_login": "2024-01-20T00:08:11.478Z",
  "last_platform": "standalonewindows",
  "allowAvatarCopying": true,
  "status": "join me",
  "date_joined": "2022-04-06",
  "isFriend": false,
  "friendKey": "...",
  "last_activity": "2024-01-20T00:07:57.440Z",
  "onlineFriends": [
    "..."
  ],
  "activeFriends": [
    "..."
  ],
  "presence": {
    "instance": "...",
    "isRejoining": "0",
    "platform": "standalonewindows",
    "instanceType": "group",
    "groups": [
      "..."
    ],
    "currentAvatarTags": "",
    "profilePicOverride": "",
    "status": "join me",
    "userIcon": "",
    "debugflag": "5",
    "world": "...",
    "displayName": "...",
    "travelingToWorld": "",
    "travelingToInstance": "",
    "id": "...",
    "avatarThumbnail": "..."
  },
  "offlineFriends": [
    "..."
  ]
}

It looks like presence.currentAvatarTags/debugflag/isRejoining/userIcon and acceptedPrivacyVersion/googleId/picoId/viveId are missing, but adding them doesn't solve my error.

EDIT: It looks like it's caused by past_display_names: Vec<Either<PastDisplayName, String>>
updated_at needs to be renamed to updated_at and for some reason Either<Struct, String> doesn't work, it has to be Vec<Struct>