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

Clarify how to use edit tokens #29

Open
lucaswerkmeister opened this issue Sep 24, 2019 · 0 comments
Open

Clarify how to use edit tokens #29

lucaswerkmeister opened this issue Sep 24, 2019 · 0 comments

Comments

@lucaswerkmeister
Copy link

This library’s handling of edit tokens is currently a bit inconsistent, I think:

  • Most of the “crud operations” (create, edit, move etc.) read the token from this.editToken, and that member is also used once in the README. It’s not mentioned in API.md, though.
  • The token is also stored in this.state, as this.state.csrftoken.
  • getEditToken() returns a Promise that resolves with this.state, not the edit token directly. This is not documented in API.md, though.

I have no idea which of these should be used when making a request directly with request(). this.editToken looks good, but it’s unclear if it’s part of the stable interface. getEditToken() is part of the stable interface, but resolves with an undocumented value that looks more like an implementation detail than this.editToken. Can you clarify this?

siddharthvp added a commit to siddharthvp/mwn that referenced this issue Apr 8, 2020
Fetch a new edit token on badtoken errors and retry.

getEditToken() is modified to always fetch a new token,
rather than abort if the token is already set.
Also, make getEditToken() return the token itself (wrapped in
a promise) rather than this.state (which doesn't make sense).

Addresses the mwbot issue gesinn-it-pub/mwbot#29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant