Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tells me to sign in again after getting cache #106

Closed
2 tasks
bunningtonfoot opened this issue Jul 3, 2024 · 12 comments
Closed
2 tasks

Tells me to sign in again after getting cache #106

bunningtonfoot opened this issue Jul 3, 2024 · 12 comments

Comments

@bunningtonfoot
Copy link

  • The readme doesn't contain a resolution to my issue
  • The example doesn't contain a resolution to my issue

Versions

  • node: v21
  • prismarine-auth: 2.5.0

issue

When I use flow to sign in to my account, I have to login once more before it can join a realm. This is an issue because It’s NOT suppose to do that, so I can’t have people linking their main account to a bot for realms anti cheat. I don’t know how to explain more but it would be nice if the TODO: part worked.

Additional context

The caching doesn’t work, and it’s quite annoying. I’ve tried everything and I still cannot get it to read the cached tokens.

@LucienHH
Copy link
Contributor

LucienHH commented Jul 3, 2024

Can you please share the code you are using

@ghost
Copy link

ghost commented Jul 3, 2024

const client = new Authflow(
undefined,
userDir,
{
flow: "live",
authTitle: Titles.MinecraftNintendoSwitch,
deviceType: "Nintendo",
doSisuAuth: true
},
async (code) => {
I also get the token, the files go into the correct spot it’s just they aren’t read the first time it starts but here’s how I create it
const directoryPath = path.join(__dirname, ../authorized_users/${user_id})

const client = await createClient({
    autoInitPlayer: true,
    username: `${gamertag}`,
    profilesFolder: `${directoryPath}`,
    skinData: {
        CurrentInputMode: 6,
        DefaultInputMode: 6,
        DeviceModel: 'Orbis',
        DeviceOS: 11,
    },
    skipPing: true,
    
    realms: {
        realmInvite: realmCode,
    }
});

@LucienHH
Copy link
Contributor

LucienHH commented Jul 3, 2024

Why are you creating an authflow before createClient? Unless you're doing it for your own needs, creating an Authflow is handled within createClient so that could be why you're having to sign in twice. Once for your own authflow and another for the authflow within createClient.

@bunningtonfoot
Copy link
Author

bunningtonfoot commented Jul 3, 2024

The user links their account, and the create client is in my util file, it’s made for realm owners to link their account, and then use /connect to connect their linked account to the chosen realm. But this won’t work since I have to sign in again. The link command is suppose to store the users cache and use it to login to the realm.

@LucienHH
Copy link
Contributor

LucienHH commented Jul 3, 2024

If the first authflow is your link then you need to make sure the directory match so userDir and directoryPath need to point to the same location and also the username needs to match as that is what's used to create a hash. The first argument of Authflow and username in createClient need to be the same. At the moment you're passing undefined to the authflow when it should be gamertag based on your createClient options

@bunningtonfoot
Copy link
Author

When I link all the cache is correct but when it tells me to sign in again it remakes 2 cache files with different names and the directory’s are good, too.

@LucienHH
Copy link
Contributor

LucienHH commented Jul 3, 2024

Yes that's why you need to match the username identifiers in both the authflow and the createClient as explained they are used to generate a hash for the file names.

@bunningtonfoot
Copy link
Author

bunningtonfoot commented Jul 3, 2024

I understand now, will undefined work if I put it in the create client?

@LucienHH
Copy link
Contributor

LucienHH commented Jul 3, 2024

In theory yes if each user has their own directory but I'd define a username to be consistent so you can easily identify a user's cached files. You can use the userid that's also being used to define the directory

@bunningtonfoot
Copy link
Author

Yes, each user has there own folder created with their discord id.

@LucienHH
Copy link
Contributor

LucienHH commented Jul 3, 2024

Ok just use that as the username param then for both authflow and createClient

@bunningtonfoot
Copy link
Author

Omg tysm! Idk why I never tried that, I was thinking about it lol 😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants