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

Client_Secret Error #29

Open
notzairdev opened this issue Jun 19, 2024 · 5 comments
Open

Client_Secret Error #29

notzairdev opened this issue Jun 19, 2024 · 5 comments

Comments

@notzairdev
Copy link

I have had this problem when using the library when creating an Auth with Microsoft despite having my Application ID, Secret ID.

invalid_client: The provided value for the 'client_secret' parameter is not valid.
at getToken (C:\Users\PC1\Documents\HTML Proyects\Minecraft-Launcher\node_modules\minecraft-auth\dist\MicrosoftAuth\MicrosoftAuth.js:183:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.authFlow (C:\Users\PC1\Documents\HTML Proyects\Minecraft-Launcher\node_modules\minecraft-auth\dist\MicrosoftAuth\MicrosoftAuth.js:267:22)
at async MicrosoftAccount.authFlow (C:\Users\PC1\Documents\HTML Proyects\Minecraft-Launcher\node_modules\minecraft-auth\dist\MicrosoftAuth\MicrosoftAccount.js:45:20)
at async C:\Users\PC1\Documents\HTML Proyects\Minecraft-Launcher\scripts\resources\providers\launcher.provider.js:21:17 {
additionalInfo: 'a73a54c9-5c44-4b0a-9910-7cae8bc8c379'
}

@dommilosz
Copy link
Owner

Can you send minimal reproducible example code?

@notzairdev
Copy link
Author

`
async function getXboxAuth() {
return new Promise(async (resolve) => {
const MicrosoftAuth = _auth.MicrosoftAuth;

    let account = new _auth.MicrosoftAccount();
    MicrosoftAuth.setup({
        appID: process.env.MICROSOFT_CLIENTID,
        appSecret: process.env.MICROSOFT_APPSECRET,
    });

    try {
        let pkce = MicrosoftAuth.generatePKCEPair();
        let code = await MicrosoftAuth.listenForCode({pkcePair: pkce});

        if (code !== undefined) {
            await account.authFlow(code);
            
            const currentDataFile = await readConfiguration();
            
            currentDataFile.account.data = account;

            const _editable = await modifyConfiguration(currentDataFile);

            if(_editable === false) throw new Error("Failed to modify configuration file");

            console.log(account)

            resolve([{isCancelled: false, account: account}]);
        }
    } catch (exception) {
        console.error(exception);
        resolve([{
            isCancelled: true,
            reason: exception
        }])
    }
})

}
`

@dommilosz
Copy link
Owner

Sorry for no error messages, you're using the library the 2nd way: Setup for web application. This way you don't use pkce at all.

let code = await MicrosoftAuth.listenForCode();

if (code !== undefined) {
   await account.authFlow(code)
}

@notzairdev
Copy link
Author

I have already tried it that way, and the error persists.

@dommilosz
Copy link
Owner

dommilosz commented Jun 20, 2024

Please ensure your client_secret is valid, it works for me fine with this code. Console.log your env variables and compare them to actual values, ensure your secret is not expired or something maybe create a new one.

async function getXboxAuth() {
    return new Promise(async (resolve) => {
        const MicrosoftAuth = _auth.MicrosoftAuth;

        let account = new _auth.MicrosoftAccount();
        MicrosoftAuth.setup({
            appID: MICROSOFT_CLIENTID,
            appSecret: MICROSOFT_APPSECRET,
        });

        let code = await MicrosoftAuth.listenForCode();

        if (code !== undefined) {
            await account.authFlow(code)
            console.log(account)
        }
    })
}

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