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

CSRF Token error #442

Closed
luisenriqueramos1977 opened this issue Sep 23, 2019 · 12 comments
Closed

CSRF Token error #442

luisenriqueramos1977 opened this issue Sep 23, 2019 · 12 comments

Comments

@luisenriqueramos1977
Copy link

luisenriqueramos1977 commented Sep 23, 2019

Dear friends,

I have been working with wikidata for sometime, but since last week , when I try to make a bulk load, I receive a CSRF error.

I mean, when I edit wikidata and write the item, I do not receive any error message and write the item, but now I receive a CSRF Token error message as shown below:

2019-09-23 09:12:42 ERROR - Gave up after several retries. Last error was: org.wikidata.wdtk.wikibaseapi.apierrors.TokenErrorException: [badtoken] Invalid CSRF token.
Exception in thread "main" 2019-09-23 09:12:42 ERROR - Gave up after several retries. Last error was: org.wikidata.wdtk.wikibaseapi.apierrors.TokenErrorException: [badtoken] Invalid CSRF token.
2019-09-23 09:12:42 ERROR - Gave up after several retries. Last error was: org.wikidata.wdtk.wikibaseapi.apierrors.TokenErrorException: [badtoken] Invalid CSRF token.
2019-09-23 09:12:42 ERROR - Gave up after several retries. Last error was: org.wikidata.wdtk.wikibaseapi.apierrors.TokenErrorException: [badtoken] Invalid CSRF token.
2019-09-23 09:12:42 ERROR - Gave up after several retries. Last error was: org.wikidata.wdtk.wikibaseapi.apierrors.TokenErrorException: [badtoken] Invalid CSRF token.
2019-09-23 09:12:42 ERROR - Gave up after several retries. Last error was: org.wikidata.wdtk.wikibaseapi.apierrors.TokenErrorException: [badtoken] Invalid CSRF token.
2019-09-23 09:12:42 ERROR - Gave up after several retries. Last error was: org.wikidata.wdtk.wikibaseapi.apierrors.TokenErrorException: [badtoken] Invalid CSRF token.
2019-09-23 09:12:42 ERROR - Gave up after several retries. Last error was: org.wikidata.wdtk.wikibaseapi.apierrors.TokenErrorException: [badtoken] Invalid CSRF token.
2019-09-23 09:12:42 ERROR - Gave up after several retries. Last error was: org.wikidata.wdtk.wikibaseapi.apierrors.TokenErrorException: [badtoken] Invalid CSRF token.
org.wikidata.wdtk.wikibaseapi.apierrors.TokenErrorException: [badtoken] Invalid CSRF token.
	at org.wikidata.wdtk.wikibaseapi.apierrors.MediaWikiApiErrorHandler.throwMediaWikiApiErrorException(MediaWikiApiErrorHandler.java:55)
	at org.wikidata.wdtk.wikibaseapi.ApiConnection.checkErrors(ApiConnection.java:466)
	at org.wikidata.wdtk.wikibaseapi.ApiConnection.sendJsonRequest(ApiConnection.java:406)
	at org.wikidata.wdtk.wikibaseapi.WbEditingAction.performAPIAction(WbEditingAction.java:716)
	at org.wikidata.wdtk.wikibaseapi.WbEditingAction.wbEditEntity(WbEditingAction.java:294)
	at org.wikidata.wdtk.wikibaseapi.WikibaseDataEditor.createItemDocument(WikibaseDataEditor.java:240)
	at wikiloader.GLEIFRegisterResponsibleLoader.main(GLEIFRegisterResponsibleLoader.java:743)

Any idea why is that happening?, is it a coding error?, or it is another kind of error?

Luis Ramos

@robertvazan
Copy link
Collaborator

@Tpt @wetneb Is this still broken? I remember from when I used Wikibase API directly that CSRF tokens expire when not used for some time. They have to be renewed periodically. This is not a problem for busy bots, but assisted editing tools will have gaps in activity that cause CSRF tokens to expire.

@luisenriqueramos1977
Copy link
Author

I solved the issue, thans

@robertvazan
Copy link
Collaborator

@luisenriqueramos1977 So what was the cause and how did you solve the problem? Can this issue be closed?

@Lhaaits
Copy link
Collaborator

Lhaaits commented Mar 2, 2023

Hi, I see this is an old issue, but I recently have also ran into this problem. For me it occurs when I try to login again after I caught an AssertUserFailedException. After debugging I think the issue is that the login method of BasicApiConnection does not have a way to reset the login token or clear the token from outside of the package.

The login method calls getOrFetchToken, but the token map is already filled from the first login. However, this token is expired. I think there should be a way to force token fetching in this case. I am however intrigued how @luisenriqueramos1977 solved the issue.

@luisenriqueramos1977
Copy link
Author

dear @robertvazan , yes you can close it, but @Lhaaits unfortunately I do not remember how I solved it that time.

@Lhaaits
Copy link
Collaborator

Lhaaits commented Mar 4, 2023

I'd like to make a pull request to enable resetting the tokens, if that's ok, so maybe you can leave it open until then

@Lhaaits
Copy link
Collaborator

Lhaaits commented Mar 30, 2023

I think this can be closed. Could someone with rights create a release for #765 ?

@Lhaaits
Copy link
Collaborator

Lhaaits commented May 3, 2023

@robertvazan could you create a release for #765?

@robertvazan
Copy link
Collaborator

@Lhaaits Hi. I am not currently actively working on WDTK for lack of time. I think releases are done by either @Tpt or @wetneb.

@wetneb
Copy link
Member

wetneb commented May 3, 2023

I am not actively working on this project either. @Lhaaits you have made multiple contributions already, would you like to help with reviewing PRs and making releases? Unless @robertvazan or @Tpt see a problem with this, I would invite you to the repository so that you can do that.

@Lhaaits
Copy link
Collaborator

Lhaaits commented Sep 20, 2023

Hi @wetneb, I think my invitation expired a while ago, could you send a new one?

@wetneb
Copy link
Member

wetneb commented Sep 20, 2023

Invite sent again, please go to https://github.com/Wikidata/Wikidata-Toolkit to accept it

@wetneb wetneb closed this as completed in 4f78f81 Jan 16, 2024
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

4 participants