Topic on Project:Support desk

ZakirH (talkcontribs)

I am getting the login token using a POST API calling this URL "http://localhost:81/mediawiki/api.php?action=query&meta=tokens&type=login&format=json" with the below post object

my post object is { lgname: test123, lgpassword: test@123 }.

Once I got the logintoken and session created, I am again doing a POST call to this URL"http://localhost:81/mediawiki/api.php?action=query&meta=tokens&type=csrf&format=json" with the below cookie information

bitnami_mediawiki_session: e6ggc1bi6jt2qck5rubgpddi6bq0jc9s; bitnami_mediawikiUserID:1;bitnami_mediawikiUserName: test123

Even after doing the above steps, I am still receiving anon token (+). Is there anything I am doing wrong or missing? Any assistance would be of great help.

Margarethkearney (talkcontribs)

I am having the same issue. Has anyone been able to figure out how to do this.

2604:6000:84C1:A900:4959:984E:73CD:B115 (talkcontribs)

    function requestCSRFtoken($wiki)

    {

        $parameters = array(

                            'action' => 'query',                     

                            'format'=>'json',

                            'maxlag'=>'10',

                            'smaxage'=>'0',

                            'maxage'=>'0',

                            'assert'=>'user',

                            'assertuser'=>'Admin2',

                            'requestid'=>'1',

                            'servedby'=>'true',

                            'curtimestamp'=>'true',

                            'responselanginfo'=>'1',

                            'origin'=>'*',

                            'uselang'=>'user',

                            'centralauthtoken'=>'123',

                            'meta'=>'tokens',

                            'type'=>'csrf'

                            );  

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $wiki);

        curl_setopt($ch, CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);

        curl_setopt($ch, CURLOPT_POST, true);

        curl_setopt($ch, CURLOPT_POSTFIELDS,  http_build_query($parameters));

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        curl_setopt($ch, CURLOPT_COOKIESESSION, true);

        curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie-name');

        curl_setopt($ch, CURLOPT_COOKIEFILE, '/var/www/ip4.x/file/tmp');

        $answer = curl_exec($ch);

        return $answer;

    }   

    $wiki = "https://breakofdaymhg.com/staff/wiki/api.php";

    //ebsh7p6e6q