MineDojo / Voyager

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

KeyError: 'access_token' when initiating #18

Closed woldioo closed 1 year ago

woldioo commented 1 year ago

I've inserted the link on the browser to the prompt after running voyager, but then the following issue occurred

Traceback (most recent call last): File "C:\Users\yangh\Documents\Voyager\run.py", line 12, in voyager = Voyager( ^^^^^^^^ File "C:\Users\yangh\Documents\Voyager\voyager\voyager.py", line 102, in init self.env = VoyagerEnv( ^^^^^^^^^^^ File "C:\Users\yangh\Documents\Voyager\voyager\env\bridge.py", line 42, in init self.mc_instance = self.get_mc_instance() ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\yangh\Documents\Voyager\voyager\env\bridge.py", line 67, in get_mc_instance return MinecraftInstance( ^^^^^^^^^^^^^^^^^^ File "C:\Users\yangh\Documents\Voyager\voyager\env\minecraft_launcher.py", line 36, in init self.mc_command = self.get_mc_command() ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\yangh\Documents\Voyager\voyager\env\minecraft_launcher.py", line 89, in get_mc_command login_data = minecraft_launcher_lib.microsoft_account.complete_login( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\yangh\AppData\Local\Programs\Python\Python311\Lib\site-packages\minecraft_launcher_lib\microsoft_account.py", line 261, in complete_login token = token_request["access_token"]


KeyError: 'access_token'

run.py is the one I made (strictly based on README.md) for running voyager

```
from voyager import Voyager

# you can also use mc_port instead of azure_login, but azure_login is highly recommended
azure_login = {
    "client_id": "[I've filled this section]",
    "redirect_url": "https://127.0.0.1/auth-response",
    "secret_value": "[this one too]",
    "version": "fabric-loader-0.14.21-1.19", # the version here has changed
}
openai_api_key = "[and this one either]"

voyager = Voyager(
    azure_login=azure_login,
    openai_api_key=openai_api_key,
)

# start lifelong learning
voyager.learn()
```
JesseRWeigel commented 1 year ago

Has anyone found a fix for this yet? GPT4 thinks it is either a permissions issue in Azure or a version issue with the minecraft_launcher_lib.

JesseRWeigel commented 1 year ago

Someone else got the same error and managed to fix it. I have not been able to recreate the fix. https://gitlab.com/JakobDev/minecraft-launcher-lib/-/issues/54

taoisu commented 1 year ago

Use "Web" instead of the "Desktop or Mobile" platform:

image
woldioo commented 1 year ago

Use "Web" instead of the "Desktop or Mobile" platform:

image

now I have this

Traceback (most recent call last): File "C:\Users\yangh\Documents\Voyager\run.py", line 12, in voyager = Voyager( ^^^^^^^^ File "C:\Users\yangh\Documents\Voyager\voyager\voyager.py", line 102, in init self.env = VoyagerEnv( ^^^^^^^^^^^ File "C:\Users\yangh\Documents\Voyager\voyager\env\bridge.py", line 42, in init self.mc_instance = self.get_mc_instance() ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\yangh\Documents\Voyager\voyager\env\bridge.py", line 67, in get_mc_instance return MinecraftInstance( ^^^^^^^^^^^^^^^^^^ File "C:\Users\yangh\Documents\Voyager\voyager\env\minecraft_launcher.py", line 36, in init self.mc_command = self.get_mc_command() ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\yangh\Documents\Voyager\voyager\env\minecraft_launcher.py", line 98, in get_mc_command "username": login_data["name"],


KeyError: 'name'
woldioo commented 1 year ago

Oh I've just realized I've logged in to wrong microsoft account which doesn't have minecraft this might be the cause, but how can I re-login?

xieleo5 commented 1 year ago

Hi all, thanks for your interest in this project! I'm not quite sure what's the cause of this issue. I tested both the web and Desktop and Mobile types on my machine, and only Desktop and Mobile works for access_token.

I think you need to make sure your app's supported account type is All Microsoft account users. You can also go to the manifest tab and make sure the accessTokenAcceptedVersion value is 2 and the signInAudience value is AzureADandPersonalMicrosoftAccount

To re-login, you can try to clear your cookies in your browser.

woldioo commented 1 year ago

Problem Solved! It was the login issue

ShimantaBhuyan commented 1 year ago

@xieleo5 I have been facing this issue and unable to start. I have tried creating a new Azure app and even tried secret id as well but I still get this same error:

Traceback (most recent call last):
  File "D:\MineDojo_Voyager\Voyager\start_voyage.py", line 12, in <module>
    voyager = Voyager(
              ^^^^^^^^
  File "D:\MineDojo_Voyager\Voyager\voyager\voyager.py", line 102, in __init__
    self.env = VoyagerEnv(
               ^^^^^^^^^^^
  File "D:\MineDojo_Voyager\Voyager\voyager\env\bridge.py", line 42, in __init__
    self.mc_instance = self.get_mc_instance()
                       ^^^^^^^^^^^^^^^^^^^^^^
  File "D:\MineDojo_Voyager\Voyager\voyager\env\bridge.py", line 67, in get_mc_instance
    return MinecraftInstance(
           ^^^^^^^^^^^^^^^^^^
  File "D:\MineDojo_Voyager\Voyager\voyager\env\minecraft_launcher.py", line 36, in __init__
    self.mc_command = self.get_mc_command()
                      ^^^^^^^^^^^^^^^^^^^^^
  File "D:\MineDojo_Voyager\Voyager\voyager\env\minecraft_launcher.py", line 89, in get_mc_command
    login_data = minecraft_launcher_lib.microsoft_account.complete_login(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\bhuya\AppData\Roaming\Python\Python311\site-packages\minecraft_launcher_lib\microsoft_account.py", line 261, in complete_login
    token = token_request["access_token"]
            ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'access_token'

Please help on how to proceed.

nathan-gage commented 1 year ago

Problem Solved! It was the login issue

What do you mean by login issue?

woldioo commented 1 year ago

like I said, I had logged in to a wrong account

steppelord commented 1 year ago

Can confirm this issue is still occurring for me and I am logged in with the right account.

taoisu commented 1 year ago

@steppelord it may be helpful if you can find the exact error message from login (the message before trying to get access_token), in my case it states clearly I need to use a different platform.