mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Use central auth token only for cross wiki calls (#2318)
* Use central auth token only for cross wiki calls * Fix tests * Add test for wikidata edit token
This commit is contained in:
parent
de9611821b
commit
68ae11e37f
3 changed files with 24 additions and 13 deletions
|
|
@ -230,7 +230,6 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
|
|||
@Override
|
||||
public String getEditToken() throws IOException {
|
||||
String editToken = api.action("query")
|
||||
.param("centralauthtoken", getCentralAuthToken())
|
||||
.param("meta", "tokens")
|
||||
.post()
|
||||
.getString("/api/query/tokens/@csrftoken");
|
||||
|
|
@ -288,7 +287,6 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
|
|||
return api.action("edit")
|
||||
.param("title", filename)
|
||||
.param("token", getEditToken())
|
||||
.param("centralauthtoken", getCentralAuthToken())
|
||||
.param("text", processedPageContent)
|
||||
.param("summary", summary)
|
||||
.post()
|
||||
|
|
@ -302,7 +300,6 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
|
|||
return api.action("edit")
|
||||
.param("title", filename)
|
||||
.param("token", getEditToken())
|
||||
.param("centralauthtoken", getCentralAuthToken())
|
||||
.param("appendtext", processedPageContent)
|
||||
.param("summary", summary)
|
||||
.post()
|
||||
|
|
@ -315,7 +312,6 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
|
|||
return api.action("edit")
|
||||
.param("title", filename)
|
||||
.param("token", getEditToken())
|
||||
.param("centralauthtoken", getCentralAuthToken())
|
||||
.param("prependtext", processedPageContent)
|
||||
.param("summary", summary)
|
||||
.post()
|
||||
|
|
@ -895,7 +891,7 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
|
|||
Uri contentProviderUri,
|
||||
final ProgressListener progressListener) throws IOException {
|
||||
|
||||
CustomApiResult result = api.upload(filename, file, dataLength, pageContents, editSummary, getCentralAuthToken(), getEditToken(), progressListener::onProgress);
|
||||
CustomApiResult result = api.upload(filename, file, dataLength, pageContents, editSummary, getEditToken(), progressListener::onProgress);
|
||||
|
||||
Timber.d("Result: %s", result.toString());
|
||||
|
||||
|
|
|
|||
|
|
@ -131,20 +131,19 @@ public class CustomMwApi {
|
|||
}
|
||||
}
|
||||
|
||||
public CustomApiResult upload(String filename, InputStream file, long length, String text, String comment, String centralAuthToken, String token) throws IOException {
|
||||
return this.upload(filename, file, length, text, comment,centralAuthToken, token, null);
|
||||
public CustomApiResult upload(String filename, InputStream file, long length, String text, String comment, String token) throws IOException {
|
||||
return this.upload(filename, file, length, text, comment, token, null);
|
||||
}
|
||||
|
||||
public CustomApiResult upload(String filename, InputStream file, String text, String comment, String centralAuthToken, String token) throws IOException {
|
||||
return this.upload(filename, file, -1, text, comment,centralAuthToken, token, null);
|
||||
public CustomApiResult upload(String filename, InputStream file, String text, String comment, String token) throws IOException {
|
||||
return this.upload(filename, file, -1, text, comment, token, null);
|
||||
}
|
||||
|
||||
public CustomApiResult upload(String filename, InputStream file, long length, String text, String comment, String centralAuthToken, String token, ProgressListener uploadProgressListener) throws IOException {
|
||||
public CustomApiResult upload(String filename, InputStream file, long length, String text, String comment, String token, ProgressListener uploadProgressListener) throws IOException {
|
||||
Timber.d("Initiating upload for file %s", filename);
|
||||
Http.HttpRequestBuilder builder = Http.multipart(apiURL)
|
||||
.data("action", "upload")
|
||||
.data("token", token)
|
||||
.data("centralauthtoken", centralAuthToken)
|
||||
.data("text", text)
|
||||
.data("ignorewarnings", "1")
|
||||
.data("comment", comment)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue