darthbhyrava added a comment.

@jayvdb, the entire script has been linked to in T135409#2373533. Here's the method involved:

def thank_rev(rev_id):
    """
    Thank the given revision ID on the wiki on behalf of the user logged in.
    """
    #Login into the wiki
    site = pywikibot.Site()
    site.login()
    #Get csrf token from site.
    token = site.tokens['csrf']
     
    # print rev_id
    # print token

    values = {'rev' : rev_id,
              'source' : 'test_thank',
              'token' : token }
    r = requests.post("https://test.wikipedia.org/w/api.php?action="" data=""
    print (r.text)

The user name used is 'darthbhyrava'. If I print the token, and use in the API sandbox, it works. But the script returns the value:

{"servedby":"mw1197","error":{"code":"badtoken","info":"Invalid token","*":"See https://test.wikipedia.org/w/api.php for API usage"}}

TASK DETAIL
https://phabricator.wikimedia.org/T135409

EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: darthbhyrava
Cc: Zppix, Xqt, Mpaa, valhallasw, kaldari, polybuildr, 01tonythomas, pywikibot-bugs-list, Aklapper, Sumit, darthbhyrava, Legoktm, jayvdb, Lethexie, fbstj, Catrope, Jay8g
_______________________________________________
pywikibot-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs

Reply via email to