DD063520 added a comment.
Hi, this is the consumer: https://meta.wikimedia.org/w/index.php?title=Special:OAuthListConsumers/view/25909aad6dde148a8fb348fd19f36b62&name=&publisher=DD063520&stage=-1 so there should be the necessary grants. I will past here the two relevant code snippets. This part is working: OAuthRequest request = new OAuthRequest(Verb.POST, API); request.addBodyParameter("action","query"); request.addBodyParameter("meta","userinfo"); request.addBodyParameter("format","json"); service.get().signRequest(newAccess, request); Response response = service.get().execute(request); JSONParser parser = new JSONParser(); JSONObject jsonObject = (JSONObject) parser.parse(response.getBody()); System.out.println(jsonObject); user.setUserName(((JSONObject)((JSONObject) jsonObject.get("query")).get("userinfo")).get("name").toString()); userRepository.save(user); i.e. I can retrieve the user information. While this part: OAuthRequest request = new OAuthRequest(Verb.POST, API + "?action=query&format=json&meta=tokens"); OAuth1AccessToken newAccess = new OAuth1AccessToken(user.getAccessToken(),user.getAccessTokenSecret()); service.get().signRequest(newAccess, request); Response response = service.get().execute(request); System.out.println(response.getBody()); System.out.println(response.getHeaders().get("Set-Cookie")); JSONParser parser = new JSONParser(); JSONObject jsonObject = (JSONObject) parser.parse(response.getBody()); String csrftoken = ((JSONObject) ((JSONObject) jsonObject.get("query")).get("tokens")).get("csrftoken").toString(); System.out.println(csrftoken); //doesn't work System.out.println("Cookie "+user.getWikidataToken()); request = new OAuthRequest(Verb.POST, API); //this line also doesn't help request.getHeaders().put("cookie=",user.getWikidataToken()); request.addBodyParameter("action", "wbsetdescription"); request.addBodyParameter("id", "Q47545479"); request.addBodyParameter("language", "it"); request.addBodyParameter("value", "Sistema di Question Answering per dati in formato RDF"); request.addBodyParameter("format", "json"); request.addBodyParameter("token", csrftoken); service.get().signRequest(newAccess, request); response = service.get().execute(request); works only the first part, the second gets the above mentioned error. Let me know if you need more details .... TASK DETAIL https://phabricator.wikimedia.org/T246751 EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/ To: DD063520 Cc: Lucas_Werkmeister_WMDE, DD063520, Aklapper, darthmon_wmde, Nandana, Lahi, Gq86, GoranSMilovanovic, QZanden, LawExplorer, _jensen, rosalieper, Scott_WUaS, Wikidata-bugs, aude, Mbch331
_______________________________________________ Wikidata-bugs mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs
