dommilosz / minecraft-auth

29 stars 3 forks source link

public client must include a 'client_secret' input parameter #28

Closed bamlakamare closed 2 months ago

bamlakamare commented 2 months ago

while using the default app id or custom it throwing this error 'invalid_client: The provided request must include a 'client_secret' input parameter.'

dommilosz commented 2 months ago

Yeah, I can reproduce the issue. Maybe they changed something. I'll look into it.

dommilosz commented 2 months ago

Well... https://help.minecraft.net/hc/en-us/articles/16254801392141 they need to verify apis now. I'll try to apply but for now you can create your own application and use it in web mode not spa mode as it's described here: https://github.com/dommilosz/minecraft-auth/wiki/How-to-setup-Microsoft-Auth#setup-for-web-application

bamlakamare commented 2 months ago

i tried that but its returning an undefined access token even if the user has a minecraft account, i checked with another service (https://minecraftauth.me) and it detects the account there, i guess you have to register in both cases

Screenshot 2024-04-11 at 10 13 58 at night
dommilosz commented 2 months ago

It works fine in my own app in Web mode when I provide client secret. Maybe old apps continue to have access? I've sent the form I'll let you know if they respond.

dommilosz commented 2 months ago

I got email saying they've approved the application. Can you try test it? Please note the appid changed in the wiki.

bamlakamare commented 2 months ago

i tried it with your appid, returning " Proof Key for Code Exchange is required for cross-origin authorization code redemption"

Screenshot 2024-04-15 at 11 43 55 in the morning
dommilosz commented 2 months ago

Please update the library to 2.0.9

dommilosz commented 2 months ago

It doesn't work for me yet. They said it can take up to 14 hours.

dommilosz commented 2 months ago

It appears to be working now! Please let me know if that's also the case for you. Make sure you're using correct appId ("74c5dc2a-449c-4224-8fe5-ca83ac47f48c")

bamlakamare commented 2 months ago

they also approuved my request and now it works when i add the app secrate but, when using your appid its returning the same error "Proof key for code exchange", maybe you forgot to add the redirect url under the web platform?

dommilosz commented 2 months ago

Have you updated it to 2.0.9?

bamlakamare commented 2 months ago

yes

dommilosz commented 2 months ago

That's weird. Can you post code that causes that error?

bamlakamare commented 2 months ago

`async function f() { try { const MicrosoftAuth = minecraftAuth.MicrosoftAuth;

    let account = new minecraftAuth.MicrosoftAccount();
    MicrosoftAuth.setup({appID:"74c5dc2a-449c-4224-8fe5-ca83ac47f48c"});
    let code = await MicrosoftAuth.listenForCode();

    if(code !== undefined){
        let res = await account.authFlow(code);
        console.log(account)
    }
}
catch (e) {
    console.log(e)
}

}

f()`

dommilosz commented 2 months ago

Oh yeah, I forgot to update the documentation. You need to generate PKCE pair for it to work

(async ()=>{
const MicrosoftAuth = minecraftAuth.MicrosoftAuth;

let account = new minecraftAuth.MicrosoftAccount();
MicrosoftAuth.setup({appID:"74c5dc2a-449c-4224-8fe5-ca83ac47f48c"});

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

if(code !== undefined){
   await account.authFlow(code, pkce);
   await account.use();
   console.log(account)
   console.log(account.accessToken)
   console.log(await account.getProfile());
   console.log(account.username);
   console.log(account.profile?.name);
}

})();
bamlakamare commented 2 months ago

noice it works, thanks