maxlath / wikibase-cli

read and edit a Wikibase instance from the command line
MIT License
227 stars 24 forks source link

login does not work #153

Closed EvaSeidlmayer closed 2 years ago

EvaSeidlmayer commented 2 years ago

Hey, stupid issue, I know.... but... when I try to create an entity using wb create-entity new.json I always get the error message claiming I am not logged in. failed to login: invalid username/password undefined However, I am logged in, which I checked by wb config:

{
  "instance": "https://www.wikidata.org",
  "credentials": {
    "https://www.wikidata.org": {
      "username": "X@Y",
      "password": "lmnopqrst"
    }
  },
  "bot": true
}

What can be the reason? Sorry, for this basic issue but I running mad about this.

maxlath commented 2 years ago

I can't think of a reason why that would fail other than the username or password being invalid: what does the following command give you? wb config credentials https://www.wikidata.org test

EvaSeidlmayer commented 2 years ago
wb config credentials https://www.wikidata.org test
{ Error: failed to login: invalid username/password
    at Object.new (/usr/local/lib/node_modules/wikibase-cli/node_modules/wikibase-edit/lib/error.js:3:17)
    at /usr/local/lib/node_modules/wikibase-cli/node_modules/wikibase-edit/lib/request/login.js:44:21
    at process._tickCallback (internal/process/next_tick.js:68:7) statusCode: 400 }
https://www.wikidata.org credentials are invalid

So maybe the credentials for the bot have expired? Earlier I also tried to change the credentials to my normal user access data by wb config credentials https://wikidata.org but I did not manage to do so.

maxlath commented 2 years ago

I don't know if that could have played a role but the Wikidata domain is https://www.wikidata.org and not https://wikidata.org as in your last comment: could that be that your config contains credentials for https://wikidata.org and not https://www.wikidata.org?

EvaSeidlmayer commented 2 years ago

Okay, I reset my password and updated my credentials. I made sure the credentials refer to https://www.wikidata.org .

However, when I now try to set the bot flag (wb config bot true) nothing happens. Can I maybe find the credentials-json-file somewhere and change to "bot":true manually in the editor? Thank you for answering my questions!

maxlath commented 2 years ago

You're welcome :)

When successful, the command wb config bot true updates the config, outputs nothing, and exits with a 0 code to signal that everything went fine: in short, it's normal that nothing happens.

You can see the state of your configuration with wb config and find the path of the file in which it is stored with wb config path.

EvaSeidlmayer commented 2 years ago

Great. As you said: The bot flag is in the config file. when I run my program I get the error message: assertbotfailed: assertbotfailed: You do not have the "bot" right, so the action could not be completed. However, I have the bot right. Do you have any idea what is missing?

maxlath commented 2 years ago

Could that be that the credentials are not those that match your bot rights? I haven't being working with bot mode, so I'm not so knowledgeable, but maybe @rwst (who's the last one appearing in bot mode with wikibase-cli) would know?

rwst commented 2 years ago

Let's compare, when I say wb config --json I get

{
  "credentials": {
    "https://www.wikidata.org": {
      "username": "Scidudebot",
      "password": ...
    }
  },
  "bot": true,
  "maxlag": 5
}

Note the username is not my username but that of my bot account. Is your config similar?

EvaSeidlmayer commented 2 years ago

my config file is this:

{
  "instance": "https://www.wikidata.org",
  "credentials": {
    "https://www.wikidata.org": {
      "username": "bot@bot",
      "password": "..."
    },
    "https://www.wikidata.org/w/api.php": {
      "username": "bot@bot",
      "password": "..."
    }
  },
  "bot": true
}

It was refused to register as "bot" (the real bot name is different) instead of "bot@bot" when I tried.

rwst commented 2 years ago

I don't know about the duplication but "bot@bot" doesn't seem like a Wikidata account name, and the page https://www.wikidata.org/wiki/User:Bot@bot leads nowhere. You need to give the Wikidata account name of your bot account.

rwst commented 2 years ago

See https://www.wikidata.org/wiki/Wikidata:Bots#Bot_accounts

EvaSeidlmayer commented 2 years ago

Great. So maybe now we get to the core problem :) This is the bot: https://www.wikidata.org/wiki/Wikidata:Requests_for_permissions/Bot/Orcbot But https://www.wikidata.org/wiki/User:Orcbot@Orcbot does not work either.

Actually, I used the bot about a year ago. I then had to stop it in order to change something in the code.

EvaSeidlmayer commented 2 years ago

The bot@bot thing was created from the special pages:

"The bot password for bot name "Orcbot" of user "Orcbot" was created. The new password to log in with Orcbot@Orcbot is xyzxyzxy. Please record this for future reference. (For old bots which require the login name to be the same as the eventual username, you can also use Orcbot as username and Orcbot@xyzxyzxyz as password.) Return to Special:BotPasswords."

rwst commented 2 years ago

Have you tried "Orcbot" as username in the wb config and its Wikidata password?

rwst commented 2 years ago

OK I just see the bot no longer has the botflag, you will have to apply again I'm afraid.

rwst commented 2 years ago

You can check the existence of the bot flag via https://www.wikidata.org/w/index.php?title=Special:UserRights/Orcbot&user-reason= This is one of the links offered on top of the page https://www.wikidata.org/wiki/Wikidata:Requests_for_permissions/Bot/Orcbot

EvaSeidlmayer commented 2 years ago

@rwst @maxlath , thank you very much! I applied for the Orcbot again.... Hope this will work out and the granting of new rights will solve the issues. Best regards! Eva

EvaSeidlmayer commented 2 years ago

Supplement: The main issue was the wrong specified bot password. When I created the bot password I missed to add "Create, edit, and move pages".

maxlath commented 2 years ago

@EvaSeidlmayer so now it works as expected? can this issue be closed?

EvaSeidlmayer commented 2 years ago

@maxlath ja! thank you!