Logging in to use action=edit from within Bash

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Logging in to use action=edit from within Bash

geoffreydebelie
Hi,

I'm trying to append text to a page as logged in MediaWiki user from within Bash.

I tried this, but it's very outdated:

I had updated it to this:


Can someone please provide me with at least a partial solution? I'm lost.

Kind regards,
Geoffrey De Belie


_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: Logging in to use action=edit from within Bash

Martin Urbanec
Hi, 
Maybe pywikibot will be more better than doing this using clean Bash. Have a look at Manual:Pywikibot at MediaWiki.org. 

Best, 
Martin Urbanec 

Dne po 30. led 2017 20:20 uživatel geoffreydebelie <[hidden email]> napsal:
Hi,

I'm trying to append text to a page as logged in MediaWiki user from within Bash.

I tried this, but it's very outdated:

I had updated it to this:


Can someone please provide me with at least a partial solution? I'm lost.

Kind regards,
Geoffrey De Belie

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: Logging in to use action=edit from within Bash

geoffreydebelie
Hi,

I need to integrate it with other Bash code, so pywikibot is really overkill for just a single edit on a few pages :)

Kind regards,
Geoffrey De Belie

---- On ma, 30 jan 2017 20:26:10 +0100 Martin Urbanec <[hidden email]> wrote ----

Hi, 
Maybe pywikibot will be more better than doing this using clean Bash. Have a look at Manual:Pywikibot at MediaWiki.org. 

Best, 
Martin Urbanec 

Dne po 30. led 2017 20:20 uživatel geoffreydebelie <[hidden email]> napsal:

_______________________________________________
Mediawiki-api mailing list

Hi,

I'm trying to append text to a page as logged in MediaWiki user from within Bash.

I tried this, but it's very outdated:

I had updated it to this:


Can someone please provide me with at least a partial solution? I'm lost.

Kind regards,
Geoffrey De Belie

_______________________________________________
Mediawiki-api mailing list


_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: Logging in to use action=edit from within Bash

Martin Domdey
In reply to this post by geoffreydebelie
But is it possible to do this using clean bash?

Martin
--
Diese Nachricht wurde von meinem Android Mobiltelefon mit GMX Mail gesendet.
Am 30.01.2017, 20:26, Martin Urbanec <martin.urbanec@wikimedia.cz> schrieb:
Hi, 
Maybe pywikibot will be more better than doing this using clean Bash. Have a look at Manual:Pywikibot at MediaWiki.org. 

Best, 
Martin Urbanec 

Dne po 30. led 2017 20:20 uživatel geoffreydebelie <[hidden email]> napsal:
Hi,

I'm trying to append text to a page as logged in MediaWiki user from within Bash.

I tried this, but it's very outdated:

I had updated it to this:


Can someone please provide me with at least a partial solution? I'm lost.

Kind regards,
Geoffrey De Belie

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
_______________________________________________ Mediawiki-api mailing list [hidden email] https://lists.wikimedia.org/mailman/listinfo/mediawiki-api

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: Logging in to use action=edit from within Bash

geoffreydebelie
I think so. But I don't know how exactly. The script I've found includes cookie handling, which I think is needed in order to make use of clientlogin.

Geoffrey

---- On ma, 30 jan 2017 20:32:11 +0100 Martin Domdey <[hidden email]> wrote ----

But is it possible to do this using clean bash?

Martin
--
Diese Nachricht wurde von meinem Android Mobiltelefon mit GMX Mail gesendet.
Am 30.01.2017, 20:26, Martin Urbanec <martin.urbanec@wikimedia.cz> schrieb:
Hi, 
Maybe pywikibot will be more better than doing this using clean Bash. Have a look at Manual:Pywikibot at MediaWiki.org. 

Best, 
Martin Urbanec 


Dne po 30. led 2017 20:20 uživatel geoffreydebelie <[hidden email]> napsal:

Hi,

I'm trying to append text to a page as logged in MediaWiki user from within Bash.

I tried this, but it's very outdated:

I had updated it to this:


Can someone please provide me with at least a partial solution? I'm lost.

Kind regards,
Geoffrey De Belie

_______________________________________________
Mediawiki-api mailing list
_______________________________________________ Mediawiki-api mailing list[hidden email] https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
_______________________________________________
Mediawiki-api mailing list


_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: Logging in to use action=edit from within Bash

Gergo Tisza
In reply to this post by geoffreydebelie
It's not really clear what you are asking. Are you trying to add an edit request to that paste? What part of it is problematic?

(In any case, you probably want to use bot passwords, not clientlogin. It does work but is not ideal.)

On Mon, Jan 30, 2017 at 11:20 AM, geoffreydebelie <[hidden email]> wrote:
Hi,

I'm trying to append text to a page as logged in MediaWiki user from within Bash.

I tried this, but it's very outdated:

I had updated it to this:


Can someone please provide me with at least a partial solution? I'm lost.

Kind regards,
Geoffrey De Belie


_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api



_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: Logging in to use action=edit from within Bash

geoffreydebelie
Hi,

I had problems because of the +\\ in Bash. I was replacing those with their HTML encodings but that was preventing the code from functioning.

> Are you trying to add an edit request to that paste?
Yes. Can I just pass the CSRF token ("edit token") to action=edit and expect the MediaWiki API to know who I am?

This is the way I'm getting the CSRF token:
CR=$(curl -S \
        --location \
        --cookie $cookie_jar \
        --cookie-jar $cookie_jar \
        --user-agent "Curl Shell Script" \
        --keepalive-time 60 \
        --header "Accept-Language: en-us" \
        --header "Connection: keep-alive" \
        --compressed \
        --request "POST" "${WIKIAPI}?action=query&meta=tokens&format=json")


Kind regards,
Geoffrey

---- On ma, 30 jan 2017 21:08:13 +0100 Gergo Tisza <[hidden email]> wrote ----

 > It's not really clear what you are asking. Are you trying to add an edit request to that paste? What part of it is problematic?
 >
 > (In any case, you probably want to use bot passwords, not clientlogin. It does work but is not ideal.)
 >
 > On Mon, Jan 30, 2017 at 11:20 AM, geoffreydebelie <[hidden email]> wrote:
 >
 >
 > _______________________________________________
 > Mediawiki-api mailing list
 > [hidden email]
 > https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
 >
 > Hi,
 >
 > I'm trying to append text to a page as logged in MediaWiki user from within Bash.
 >
 > I tried this, but it's very outdated:
 > https://www.mediawiki.org/wiki/API:Client_code/Bash
 >
 > I had updated it to this:
 > http://pastebin.com/e9LF3UDa
 >
 > I want to use this: https://www.mediawiki.org/wiki/API:Edit#Editing_pages -> appendtext
 >
 > Can someone please provide me with at least a partial solution? I'm lost.
 >
 > Kind regards,
 > Geoffrey De Belie
 >
 >
 > _______________________________________________
 >  Mediawiki-api mailing list
 >  [hidden email]
 >  https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
 >  
 >



_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: Logging in to use action=edit from within Bash

Gergo Tisza
On Mon, Jan 30, 2017 at 12:25 PM, geoffreydebelie <[hidden email]> wrote:
I had problems because of the +\\ in Bash. I was replacing those with their HTML encodings but that was preventing the code from functioning.

It's actually +\ (escaped as a JSON string). You might want to use something JSON-aware like jq to process the response.
 
Can I just pass the CSRF token ("edit token") to action=edit and expect the MediaWiki API to know who I am?

The API knows who you are from the session (so you need to use cookie/cookie-jar or something similar). The CSRF token is just what its name suggests - something that verifies that you were able to read the content of the previous response.

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: Logging in to use action=edit from within Bash

Martin Urbanec
In reply to this post by Martin Domdey
It should be. At least using telnet as simple connection to the server. But I really cant find a reason for it. 

Martin

Dne po 30. led 2017 20:32 uživatel Martin Domdey <[hidden email]> napsal:
But is it possible to do this using clean bash?

Martin
--
Diese Nachricht wurde von meinem Android Mobiltelefon mit GMX Mail gesendet.
Am 30.01.2017, 20:26, Martin Urbanec <martin.urbanec@wikimedia.cz> schrieb:
Hi, 
Maybe pywikibot will be more better than doing this using clean Bash. Have a look at Manual:Pywikibot at MediaWiki.org. 

Best, 
Martin Urbanec 

Dne po 30. led 2017 20:20 uživatel geoffreydebelie <[hidden email]> napsal:
Hi,

I'm trying to append text to a page as logged in MediaWiki user from within Bash.

I tried this, but it's very outdated:

I had updated it to this:


Can someone please provide me with at least a partial solution? I'm lost.

Kind regards,
Geoffrey De Belie

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
_______________________________________________ Mediawiki-api mailing list [hidden email] https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api