MineDojo / Voyager

An Open-Ended Embodied Agent with Large Language Models
https://voyager.minedojo.org/
MIT License
5.7k stars 539 forks source link

token = token_request["access_token"] KeyError: 'access_token' #54

Closed changliucoding closed 1 year ago

changliucoding commented 1 year ago

Hi, I have one error like #34 , but I tried both Public client/native (mobile & desktop) and Web, but [None of them works]. Hope can get one solution for this , thanks!

token = token_request["access_token"] KeyError: 'access_token'

DeveloperHarris commented 1 year ago

Having this issue as well:

Traceback (most recent call last):
  File "/Users/harris/src/voyager-test/main.py", line 12, in <module>
    voyager = Voyager(
  File "/Users/harris/src/Voyager/voyager/voyager.py", line 104, in __init__
    self.env = VoyagerEnv(
  File "/Users/harris/src/Voyager/voyager/env/bridge.py", line 42, in __init__
    self.mc_instance = self.get_mc_instance()
  File "/Users/harris/src/Voyager/voyager/env/bridge.py", line 67, in get_mc_instance
    return MinecraftInstance(
  File "/Users/harris/src/Voyager/voyager/env/minecraft_launcher.py", line 36, in __init__
    self.mc_command = self.get_mc_command()
  File "/Users/harris/src/Voyager/voyager/env/minecraft_launcher.py", line 74, in get_mc_command
    code_url = input()
KeyboardInterrupt

Tried mobile & web but neither worked. Will dive into it to figure out why.

DeveloperHarris commented 1 year ago

Turns out the error occurs on line 324 of the microsoft_account.py file in microsoft-launcher-lib. For some reason the get_authorization_token() function fails to return the expect JSON .

DeveloperHarris commented 1 year ago

I went ahead and started diving into it, and at least for me, it seems to be an issue with the complete_login function of minecraft-launcher-lib. Specifically on line 355 in microsoft_account.py

account_request = authenticate_with_minecraft(userhash, xsts_token)

returns with a 403 FORBIDDEN.

I've tried completing the flow with and without the client secret, since it's now depreciated but no luck. Always {'path': '/authentication/login_with_xbox', 'error': 'FORBIDDEN'}. Will continue looking into it.

xieleo5 commented 1 year ago

@DeveloperHarris Hi, thanks a lot for your investigation. Since I cannot reproduce this error on my machine. I cannot provide further help. Maybe you can try to read the original login guide from minecraft-launcher-lib or create an issue there. If you have any findings, welcome to share them here.

steppelord commented 1 year ago

Also having this issue, curious are you using a third party microsoft account? E.g. through gmail

DeveloperHarris commented 1 year ago

Unfortunately the login guide from minecraft-launcher-lib doesn't provide any help here so I ended up digging through the code to try and debug, and while I narrowed it down to the authenticate_with_minecraft() call, I couldn't find any reason why minecraft-launcher-lib was getting a 403 Forbidden error during the Minecraft Oauth2 flow, especially because it successfully authenticated with Microsoft & Xbox, but couldn't authenticate with Minecraft's API.

I'm using my Microsoft account (attached to my Gmail). I recently had to link my Minecraft account to my Microsoft account, so maybe it has something to do with that? Unsure. Either way, I ended up just using the mc_port method to get it to work.

More info on the oauth2 flow can be found at https://wiki.vg/Microsoft_Authentication_Scheme

tegnike commented 1 year ago

I have same issue.

C:\Users\xxxxx\anaconda3\lib\site-packages\minecraft_launcher_lib\microsoft_account.py

def authenticate_with_minecraft(userhash: str, xsts_token: str) -> MinecraftAuthenticateResponse:
    """
    Authenticate with Minecraft
    """
    parameters = {
        "identityToken": f"XBL3.0 x={userhash};{xsts_token}"
    }
    header = {
        "Content-Type": "application/json",
        "user-agent": get_user_agent(),
        "Accept": "application/json"
    }
    r = requests.post("https://api.minecraftservices.com/authentication/login_with_xbox", json=parameters, headers=header)
    import pdb; pdb.set_trace() 
    return r.json()
(Pdb) r
--Return--
> c:\users\xxxxx\anaconda3\lib\site-packages\minecraft_launcher_lib\microsoft_account.py(230)authenticate_with_minecraft()->{'error': 'FORBIDDEN', 'path': '/authenticat...gin_with_xbox'}
-> return r.json()
lukaemon commented 1 year ago

Got the same error as well with both web and Public client/native. Start digging.

tegnike commented 1 year ago

yse, I tried both conditions, but it' doesn't work.

Why we got 403 error?
Which authentication we couldn't pass?

lukaemon commented 1 year ago

Gave up and use mc_port. Works.

GoingMyWay commented 1 year ago

Unfortunately the login guide from minecraft-launcher-lib doesn't provide any help here so I ended up digging through the code to try and debug, and while I narrowed it down to the authenticate_with_minecraft() call, I couldn't find any reason why minecraft-launcher-lib was getting a 403 Forbidden error during the Minecraft Oauth2 flow, especially because it successfully authenticated with Microsoft & Xbox, but couldn't authenticate with Minecraft's API.

I'm using my Microsoft account (attached to my Gmail). I recently had to link my Minecraft account to my Microsoft account, so maybe it has something to do with that? Unsure. Either way, I ended up just using the mc_port method to get it to work.

More info on the oauth2 flow can be found at https://wiki.vg/Microsoft_Authentication_Scheme

Hi, do you know how to make MC running in the backend via using the mc_port method? While running, I cannot move the mouse cursor out of the game.

tegnike commented 1 year ago

@lukaemon
Thanks advice!! I counld start Voyager.

Do you know the difference of these ways to play? mc_port way is not recommended?

lukaemon commented 1 year ago

Don't know the reason. I saw in other issue that the author mentioned you have to restart the process manually if the process is disconnected somehow with mc_port. Don't know if other factors are in the play.

GoingMyWay commented 1 year ago

Don't know the reason. I saw in other issue that the author mentioned you have to restart the process manually if the process is disconnected somehow with mc_port. Don't know if other factors are in the play.

I guess that is the main reason. I ran all the iterations set in the code and did not reproduce the performance in the paper. BTW, did you manage to reproduce the results in the paper.

uetuluk commented 1 year ago

This change is the reason: https://help.minecraft.net/hc/en-us/articles/16254801392141

GoingMyWay commented 1 year ago

This change is the reason: https://help.minecraft.net/hc/en-us/articles/16254801392141

It seems we should apply for the permission.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 14 days since being marked as stale.