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

How to get login user's XUID #11

Closed
2 tasks
whes1015 opened this issue Aug 15, 2021 · 13 comments
Closed
2 tasks

How to get login user's XUID #11

whes1015 opened this issue Aug 15, 2021 · 13 comments
Labels
question Further information is requested

Comments

@whes1015
Copy link

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

Versions

  • mineflayer: #.#.#
  • server: vanilla/spigot/paper #.#.#
  • node: #.#.#

Clear question

A clear question, with as much context as possible.
What are you building? What problem are you trying to solve?

What did you try yet?

Did you try any method from the API?
Did you try any example? Any error from those?

Your current code

Please put here any custom code you tried yet.

/*
Some code here, replace this
*/

Additional context

Add any other context about the problem here.

@whes1015 whes1015 added the question Further information is requested label Aug 15, 2021
@extremeheat
Copy link
Member

Hi, what's your objective ?

I think it was removed from the current README, but this information is returned after you do a call to Authflow.getXboxToken.

{
  userXUID: string,
  userHash: string,
  XSTSToken: string,
  expiresOn: number
}

If you need a token for minecraft bedrock, the getMinecraftBedrockToken method returns three JWTs which contain the xuid and other relevant minecraft data.

@whes1015
Copy link
Author

Hi, what's your objective ?

I think it was removed from the current README, but this information is returned after you do a call to Authflow.getXboxToken.

{
  userXUID: string,
  userHash: string,
  XSTSToken: string,
  expiresOn: number
}

If you need a token for minecraft bedrock, the getMinecraftBedrockToken method returns three JWTs which contain the xuid and other relevant minecraft data.

const { Authflow } = require('prismarine-auth');

const doAuth = async() => {
const flow = new Authflow('i@heart.mineflayer', process.cwd(), { fetchProfile: true })
const response = await flow.getMinecraftBedrockToken()
console.log(response)
}

doAuth()

After I change like this,still have not get the XUID from response

@extremeheat
Copy link
Member

extremeheat commented Aug 16, 2021

What do you get in the response ? For bedrock, you need to provide a seperate keypair like in the docs here - https://github.com/PrismarineJS/prismarine-auth/blob/master/examples/bedrock/deviceCode.js

If you just want the XUID you can just call getXboxToken() with no parameters instead of getMinecraftBedrockToken.

const { Authflow } = require('prismarine-auth')
const flow = new Authflow()
flow.getXboxToken().then(console.log)

see https://github.com/PrismarineJS/prismarine-auth/blob/master/docs/API.md

@whes1015
Copy link
Author

What do you get in the response ? For bedrock, you need to provide a seperate keypair like in the docs here - https://github.com/PrismarineJS/prismarine-auth/blob/master/examples/bedrock/deviceCode.js

If you just want the XUID you can just call getXboxToken() with no parameters instead of getMinecraftBedrockToken.

const { Authflow } = require('prismarine-auth')
const flow = new Authflow()
flow.getXboxToken().then(console.log)

see https://github.com/PrismarineJS/prismarine-auth/blob/master/docs/API.md

This is my code

const doAuth = async() => {
const flow =await new Authflow()
flow.getXboxToken().then(console.log)
}

doAuth()

respone

(node:224) UnhandledPromiseRejectionWarning: Error: username is required
at new MicrosoftAuthFlow (C:\Users\whes1015\node_modules\prismarine-auth\src\MicrosoftAuthFlow.js:29:26)
at doAuth (C:\Users\whes1015\Desktop\discordbot\index.js:124:63)
at C:\Users\whes1015\Desktop\discordbot\index.js:128:47
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use node --trace-warnings ... to show where the warning was created)
(node:224) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:224) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@extremeheat
Copy link
Member

Please specify a username and caching dir for now until the master branch is released on npm

const { Authflow } = require('prismarine-auth')
const flow = new Authflow('username', './')
flow.getXboxToken().then(console.log)

@whes1015
Copy link
Author

Please specify a username and caching dir for now until the master branch is released on npm

const { Authflow } = require('prismarine-auth')
const flow = new Authflow('username', './')
flow.getXboxToken().then(console.log)

I didn't get any response

@whes1015
Copy link
Author

Please specify a username and caching dir for now until the master branch is released on npm

const { Authflow } = require('prismarine-auth')
const flow = new Authflow('username', './')
flow.getXboxToken().then(console.log)

image

@whes1015
Copy link
Author

請暫時指定用戶名和緩存目錄,直到在 npm 上發布 master 分支

const  { Authflow }  =  require ( 'prismarine-auth' ) 
const  flow  =  new  Authflow ( 'username' ,  './' ) 
flow 。獲取XboxToken ( ) 。然後(控制台。日誌)

(node:2172) UnhandledPromiseRejectionWarning: XboxReplayError: Could not exchange "userToken", please double check the specified "XSTSRelyingParty" or refer to https://bit.ly/xr-xbl-auth-user-token-issue
at Object.internal (C:\Users\whes1015\node_modules@xboxreplay\errors\dist\index.js:33:77)
at C:\Users\whes1015\node_modules\prismarine-auth\node_modules@xboxreplay\xboxlive-auth\dist\core\xboxlive\index.js:76:32
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async XboxTokenManager.getXSTSToken (C:\Users\whes1015\node_modules\prismarine-auth\src\TokenManagers\XboxTokenManager.js:149:18)
at async retry.msa.forceRefresh (C:\Users\whes1015\node_modules\prismarine-auth\src\MicrosoftAuthFlow.js:130:24)
at async retry (C:\Users\whes1015\node_modules\prismarine-auth\src\MicrosoftAuthFlow.js:22:14)
at async MicrosoftAuthFlow.getXboxToken (C:\Users\whes1015\node_modules\prismarine-auth\src\MicrosoftAuthFlow.js:120:14)
(Use node --trace-warnings ... to show where the warning was created)
(node:2172) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)
(node:2172) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[msa] First time signing in. Please authenticate now:
To sign in, use a web browser to open the page https://www.microsoft.com/link and enter the code 9JL2QUBP to authenticate.

@extremeheat
Copy link
Member

This is fixed in #13. Try:

npm i prismarinejs/prismarine-auth#docs

then see if you get the same error

@whes1015
Copy link
Author

npm iprismarinejs/prismarine-auth#docs

I got the response like this

[msa] First time signing in. Please authenticate now:
To sign in, use a web browser to open the page https://www.microsoft.com/link and enter the code YDLLJVFZ to authenticate.
[msa] Signed in as whes1015@gmail.com
[msa] First time signing in. Please authenticate now:
To sign in, use a web browser to open the page https://www.microsoft.com/link and enter the code BRA2AG8H to authenticate.

code

const doAuth = async () => {

const flow = await new Authflow('whes1015@gmail.com', './caches/')
flow.getXboxToken().then(console.log)

}

doAuth()

@whes1015
Copy link
Author

這已在#13中修復。嘗試:

npm iprismarinejs/prismarine-auth#docs

然後看看你是否得到同樣的錯誤

I was asked to log in twice and got the same reply

[msa] First time signing in. Please authenticate now:
To sign in, use a web browser to open the page https://www.microsoft.com/link and enter the code YDLLJVFZ to authenticate.
[msa] Signed in as whes1015@gmail.com
[msa] First time signing in. Please authenticate now:
To sign in, use a web browser to open the page https://www.microsoft.com/link and enter the code BRA2AG8H to authenticate.
[msa] Signed in as whes1015@gmail.com
(node:508) UnhandledPromiseRejectionWarning: XboxReplayError: Could not exchange "userToken", please double check the specified "XSTSRelyingParty" or refer to https://bit.ly/xr-xbl-auth-user-token-issue
at Object.internal (C:\Users\whes1015\node_modules@xboxreplay\errors\dist\index.js:33:77)
at C:\Users\whes1015\node_modules\prismarine-auth\node_modules@xboxreplay\xboxlive-auth\dist\core\xboxlive\index.js:76:32
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async XboxTokenManager.getXSTSToken (C:\Users\whes1015\node_modules\prismarine-auth\src\TokenManagers\XboxTokenManager.js:149:18)
at async retry.msa.forceRefresh (C:\Users\whes1015\node_modules\prismarine-auth\src\MicrosoftAuthFlow.js:130:24)
at async retry (C:\Users\whes1015\node_modules\prismarine-auth\src\MicrosoftAuthFlow.js:22:14)
at async MicrosoftAuthFlow.getXboxToken (C:\Users\whes1015\node_modules\prismarine-auth\src\MicrosoftAuthFlow.js:120:14)
(Use node --trace-warnings ... to show where the warning was created)
(node:508) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)
(node:508) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@whes1015
Copy link
Author

這已在#13 中修復。嘗試:

npm iprismarinejs/prismarine-auth#docs

然後看看你是否得到同樣的錯誤

I just want XUID, is there any other way to get it? I just want XUID,thanks

@extremeheat
Copy link
Member

extremeheat commented Aug 16, 2021

This is not a support forum, please discuss on Discord. You need to install it from git to get the latest update which fixes your issue.

npm install prismarinejs/prismarine-auth

per discord conversation, for future reference, the issue was relyingParty needs to be set to xboxlive.com.

const { Authflow, Titles } = require('prismarine-auth')
const flow = new Authflow('', './', { authTitle: Titles.MinecraftNintendoSwitch, relyingParty: 'http://xboxlive.com' })
flow.getXboxToken().then(console.log)

@rom1504 rom1504 closed this as completed Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants