unmojang / drasl

Yggdrasil-compatible API server for Minecraft
GNU General Public License v3.0
119 stars 20 forks source link

Document how to use CustomSkinLoader #50

Closed Proxwian closed 7 months ago

Proxwian commented 8 months ago

Can't find skins url to provide in CustomSkinLoader mod

evan-goode commented 8 months ago

Thanks for filing an issue, I've been meaning to document how to use this with CSL. In the meantime someone posted their CSL config in our Matrix, try this:

@ikymax:matrix.org wrote:

<@goode:matrix.org> And yeah I'd totally appreciate seeing your CSL config

"loadlist": [ { "name": "Drasl", "type": "MojangAPI", "apiRoot": "https://drasl.whatever.org/authlib-injector/minecraftservices", "sessionRoot": "https://drasl.whatever.org/authlib-injector/sessionserver" } ]

It's using the authlib injector servers, but theorically they also can use the default session and services (https://drasl.whatever.org/session and https://drasl.whatever.org/services respectively) but i haven't tried that config yet, the config is located in the CustomSkinLoader folder, its inside the instance folder and there is a file called CustomSkinLoader.json, I removed every other provider and send that config to all my players

Proxwian commented 8 months ago

[2024-03-04 18:38:31] [Kastik404/INFO] [CustomSkinLoader Core]: Default profile will be used.
Proxwian commented 8 months ago

So far it doesn't work

IkyMax commented 8 months ago

So far it doesn't work

Hey! Did You erase the original load list?

Proxwian commented 8 months ago

So far it doesn't work

Hey! Did You erase the original load list?

Yes, but I use offline account. Does it matter?

Proxwian commented 8 months ago

  "version": "14.19.1",
  "buildNumber": 26,
  "loadlist": [
    {
      "name": "OxAUTH",
      "type": "MojangAPI",
      "apiRoot": "https://oxlauncher.com/services",
      "sessionRoot": "https://oxlauncher.com/session"
    }
  ],
  "enableDynamicSkull": true,
  "enableTransparentSkin": true,
  "forceLoadAllTextures": true,
  "enableCape": true,
  "threadPoolSize": 8,
  "enableLogStdOut": false,
  "cacheExpiry": 30,
  "forceUpdateSkull": false,
  "enableLocalProfileCache": false,
  "enableCacheAutoClean": false,
  "forceDisableCache": false
}
IkyMax commented 8 months ago

Yes, but I use offline account. Does it matter?

Theoretically it shouldn't affect, could I see your current config of the mod?

Proxwian commented 8 months ago

I posted it above

IkyMax commented 8 months ago

I posted it above

Sorry, I didn't see it lmao, I see that you are using the Drasl instance itself instead of the AuthLib injector one, let me try it with the same configuration on my instance

IkyMax commented 8 months ago

  "version": "14.19.1",
  "buildNumber": 26,
  "loadlist": [
    {
      "name": "OxAUTH",
      "type": "MojangAPI",
      "apiRoot": "https://oxlauncher.com/services",
      "sessionRoot": "https://oxlauncher.com/session"
    }
  ],
  "enableDynamicSkull": true,
  "enableTransparentSkin": true,
  "forceLoadAllTextures": true,
  "enableCape": true,
  "threadPoolSize": 8,
  "enableLogStdOut": false,
  "cacheExpiry": 30,
  "forceUpdateSkull": false,
  "enableLocalProfileCache": false,
  "enableCacheAutoClean": false,
  "forceDisableCache": false
}

Hey! I have tried the same configuration (Drasl services instance and an Offline account) and everything seems to work fine, are you sure the user is registered on the instance with a skin?

IkyMax commented 8 months ago

  "version": "14.19.1",
  "buildNumber": 26,
  "loadlist": [
    {
      "name": "OxAUTH",
      "type": "MojangAPI",
      "apiRoot": "https://oxlauncher.com/services",
      "sessionRoot": "https://oxlauncher.com/session"
    }
  ],
  "enableDynamicSkull": true,
  "enableTransparentSkin": true,
  "forceLoadAllTextures": true,
  "enableCape": true,
  "threadPoolSize": 8,
  "enableLogStdOut": false,
  "cacheExpiry": 30,
  "forceUpdateSkull": false,
  "enableLocalProfileCache": false,
  "enableCacheAutoClean": false,
  "forceDisableCache": false
}

Hey! I have tried the same configuration (Drasl services instance and an Offline account) and everything seems to work fine, are you sure the user is registered on the instance with a skin?

Proxwian commented 8 months ago

image

Yes, I've taken registered username with skin

Proxwian commented 8 months ago

Can you give me example of your CSL log?

Proxwian commented 8 months ago

[2024-03-04 19:24:12] [Kastik404/INFO] [CustomSkinLoader Core]: Loading Kastik404's profile.
[2024-03-04 19:24:12] [Kastik404/INFO] [CustomSkinLoader Core]: 1/1 Try to load profile from 'OxAUTH'.
[2024-03-04 19:24:12] [Kastik404/DEBUG] [CustomSkinLoader Core]: Try to request 'https://oxlauncher.com/servicesprofiles/minecraft'.
[2024-03-04 19:24:12] [Kastik404/INFO] [CustomSkinLoader Core]: Payload: ["Kastik404"]
[2024-03-04 19:24:12] [Kastik404/DEBUG] [CustomSkinLoader Core]: Failed to request (Response Code: 404)
[2024-03-04 19:24:12] [Kastik404/INFO] [CustomSkinLoader Core]: Profile not found.(Kastik404's profile not found.)
[2024-03-04 19:24:12] [Kastik404/INFO] [CustomSkinLoader Core]: Kastik404's profile not found in load list.
Proxwian commented 8 months ago

Oh, I see it here

LMAO, lemme fix sth

Proxwian commented 8 months ago
[2024-03-04 19:29:39] [Kastik404/INFO] [CustomSkinLoader Core]: 1/1 Try to load profile from 'OxAUTH'.
[2024-03-04 19:29:40] [Kastik404/DEBUG] [CustomSkinLoader Core]: Try to request 'https://oxlauncher.com/services/profiles/minecraft'.
[2024-03-04 19:29:40] [Kastik404/INFO] [CustomSkinLoader Core]: Payload: ["Kastik404"]
[2024-03-04 19:29:40] [Kastik404/DEBUG] [CustomSkinLoader Core]: Failed to request (Response Code: 404)
[2024-03-04 19:29:40] [Kastik404/INFO] [CustomSkinLoader Core]: Profile not found.(Kastik404's profile not found.)
[2024-03-04 19:29:40] [Kastik404/INFO] [CustomSkinLoader Core]: Kastik404's profile not found in load list.

No, it doesn't help

IkyMax commented 8 months ago

Hey! I think I have already found the solution, give me a moment to try it, I'm a bit busy

IkyMax commented 8 months ago

Hello! I already saw the problem, it happens that you are using an offline account and you have not logged in with the Drasl instance in your launcher, for me, CSL was loading the cached skin, but what this mod actually does is that detect that you are in an offline account, send the user to the Mojang API and the API responds with the user's UUID and that is when the mod consults that UUID, in this case, Drasl does not have the option of returning the UUID, therefore it will only load the skins if you have already logged in to your launcher.

evan-goode commented 8 months ago

Hello! I already saw the problem, it happens that you are using an offline account and you have not logged in with the Drasl instance in your launcher, for me, CSL was loading the cached skin, but what this mod actually does is that detect that you are in an offline account, send the user to the Mojang API and the API responds with the user's UUID and that is when the mod consults that UUID, in this case, Drasl does not have the option of returning the UUID, therefore it will only load the skins if you have already logged in to your launcher.

Thanks for investigating, I'm not sure I understand completely though, do you know what route in the Mojang API CSL is requesting? My goal is for Drasl to be 100% compatible with the Mojang API, so if there's something missing I'd like to implement it. I can also look into this myself if you're not sure.

This might also be fixable by adding a new API type to CSL. Drasl will resolve offline UUIDs to the correct player (by default), so all CSL really needs to do is look up the skin normally by (either offline or online) UUID and not try to resolve player name -> UUID like you would have to do when requesting skins for offline players from Mojang's own API server.

Proxwian commented 8 months ago

You could see how offline UUID is being generated in my launcher (see ref in comment): https://github.com/Proxwian/OxLAUNCHER/blob/a64ddba605b2e922d49d1b8dd953a8a58b5327ca/src/common/reducers/actions.js#L490

evan-goode commented 8 months ago

Oh I think I see the issue, try this:

    {
      "name": "OxAUTH",
      "type": "MojangAPI",
      "apiRoot": "https://oxlauncher.com/account/",
      "sessionRoot": "https://oxlauncher.com/session/"
    }

A bug should probably be filed with CSL to automatically add in those trailing / when they're missing from the URLs.

Proxwian commented 8 months ago

A bug should probably be filed with CSL to automatically add in those trailing / when they're missing from the URLs.

Yes, and I've already did that here: https://github.com/unmojang/drasl/issues/50#issuecomment-1976991278 )

IkyMax commented 8 months ago

Thanks for investigating, I'm not sure I understand completely though, do you know what route in the Mojang API CSL is requesting? My goal is for Drasl to be 100% compatible with the Mojang API, so if there's something missing I'd like to implement it. I can also look into this myself if you're not sure.

This might also be fixable by adding a new API type to CSL. Drasl will resolve offline UUIDs to the correct player (by default), so all CSL really needs to do is look up the skin normally by (either offline or online) UUID and not try to resolve player name -> UUID like you would have to do when requesting skins for offline players from Mojang's own API server.

At least from what I understood (although i'm not 100% sure), the mod makes a request to the game profile API in mojang (e.g. https://api.mojang.com/users/profiles/minecraft/Iky_Max_) that returns the user and the UUID:

{
     "id": "297e3f89567945a594b9bcb0924f7582",
     "name": "Iky_Max_"
}

That is when the mod make a request to the session server (e.g. https://sessionserver.mojang.com/session/minecraft/profile/297e3f89567945a594b9bcb0924f7582) to get the skin url

Trying a similar path on my own Drasl instance (https://auth.lsmp.site/services/users/profiles/minecraft/Iky_Max_), it only returns the path:

{
     "path": "/services/services/users/profiles/minecraft/Iky_Max_"
}
IkyMax commented 8 months ago
{
     "path": "/services/services/users/profiles/minecraft/Iky_Max_"
}

For some reason the services section was repeated lol, but putting only one service gives the same result:

{
    "path": "/services/users/profiles/minecraft/Iky_Max_"
}
evan-goode commented 8 months ago

A bug should probably be filed with CSL to automatically add in those trailing / when they're missing from the URLs.

Yes, and I've already did that here: #50 (comment) )

Oh to clarify, in the updated config I posted, I replaced "https://oxlauncher.com/services/" with "https://oxlauncher.com/account/". Can you see if that works?

Trying a similar path on my own Drasl instance (https://auth.lsmp.site/services/users/profiles/minecraft/Iky_Max_), it only returns the path

I think the issue is that the /profiles/minecraft route CSL wants is under the "account" path, not the "services" path.

It will probably also work if you use just the base URL for both the apiRoot and sessionRoot:

    {
      "name": "OxAUTH",
      "type": "MojangAPI",
      "apiRoot": "https://oxlauncher.com/",
      "sessionRoot": "https://oxlauncher.com/"
    }
Proxwian commented 8 months ago

Oh to clarify, in the updated config I posted, I replaced "https://oxlauncher.com/services/" with "https://oxlauncher.com/account/". Can you see if that works?

YES! Actually this config worked like a charm

IkyMax commented 8 months ago

I think the issue is that the /profiles/minecraft route CSL wants is under the "account" path, not the "services" path.

It will probably also work if you use just the base URL for both the apiRoot and sessionRoot:

    {
      "name": "OxAUTH",
      "type": "MojangAPI",
      "apiRoot": "https://oxlauncher.com/",
      "sessionRoot": "https://oxlauncher.com/"
    }

Yep! It actually works, both with the account path or the base URL!

evan-goode commented 8 months ago

Nice! I'll leave this open so I remember to document it.