Remote login user/client with API call

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

Remote login user/client with API call

Daniel Edery

Hello,

I've been trying to have my user remotely sign-in through my laravel/react site, but I've been reaching a dead-end.

After reading this post from 2017 : https://laracasts.com/discuss/channels/general-discussion/single-sign-on-mechanism-for-laravel-and-mediawiki?page=0

I've followed the step for method 2 from: https://www.mediawiki.org/wiki/API:Login

I've request a login token with the api with a "GET" call of "/api.php?action=query&format=json&meta=tokens&type=login"

and received for example:

"97b2edb716fa7b13f2955c79e7f8f0205ceda2c6+\\"

Then I "POST" the result with the formData provided: (I am 100% sure those credentials are valid as I can use them to login)

  1. action:
    clientlogin
  2. username:
    TestUser
  3. password: ********
  4. loginrequests:
  5. loginmessageformat:
    wikitext
  6. loginreturnurl:
  7. logintoken:
    f90d08a1b279a521d24a4f629b678bb35ceda63d+\
  8. format:
    json

The response that I get back is:

{{{"*": "Unrecognized parameters: username, password."}},{"status": "FAIL","message": "The supplied credentials could not be authenticated.","messagecode": "authmanager-authn-no-primary"}}

What am I missing to correctly remote login a user?

Any help would be appreciated.

Daniel



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

Re: Remote login user/client with API call

Valerio Bozzolan-2
Hello,

AFAIK the parameters for the action 'clientlogin' are 'lgname' and
'lgpassword' and not 'username' and 'password'.

See the documentation:
https://www.mediawiki.org/wiki/API:Login

Anyway, hoping to be useful, here you are a little framework to
simplify that part:
https://github.com/valerio-bozzolan/boz-mw

In that way, can be just:

$wiki = \wm\MetaWiki.php::instance();
$wiki->login( $user, $password );
if( $wiki->isLogged() ) {
    echo "OK";
}

By!

On Tue, 2019-05-28 at 17:34 -0400, Daniel Edery wrote:

> Hello,
> I've been trying to have my user remotely sign-in through my
> laravel/react site, but I've been reaching a dead-end.
> After reading this post from 2017 : https://laracasts.com/discuss/cha
> nnels/general-discussion/single-sign-on-mechanism-for-laravel-and-
> mediawiki?page=0
> I've followed the step for method 2 from: https://www.mediawiki.org/w
> iki/API:Login
> I've request a login token with the api with a "GET" call of
> "/api.php?action=query&format=json&meta=tokens&type=login"
> and received for example: 
> "97b2edb716fa7b13f2955c79e7f8f0205ceda2c6+\\"
> Then I "POST" the result with the formData provided: (I am 100% sure
> those credentials are valid as I can use them to login)
> action:   clientlogin
> username:   TestUser
> password: ********
> loginrequests: 
> loginmessageformat:   wikitext
> loginreturnurl:   http://localhost:3000/
> logintoken:   f90d08a1b279a521d24a4f629b678bb35ceda63d+\
> format:   json
> The response that I get back is:
> {"warnings":{"main":{"*": "Unrecognized parameters: username,
> password."}},"clientlogin":{"status": "FAIL","message": "The supplied
> credentials could not be authenticated.","messagecode": "authmanager-
> authn-no-primary"}}
> What am I missing to correctly remote login a user?
> Any help would be appreciated.
> Daniel
>
> _______________________________________________
> Mediawiki-api mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
--
[[User:Valerio Bozzolan]]

E-mail sent using Evolution in Debian GNU/Linux without proprietary
software.

Have fun with software freedom!

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

Re: Remote login user/client with API call

Brad Jorsch (Anomie)
On Wed, May 29, 2019 at 2:11 AM Valerio Bozzolan <[hidden email]> wrote:
AFAIK the parameters for the action 'clientlogin' are 'lgname' and
'lgpassword' and not 'username' and 'password'.

You are confusing action=clientlogin with the older action=login.


On Tue, May 28, 2019 at 5:35 PM Daniel Edery <[hidden email]> wrote:
The response that I get back is:

{{{"*": "Unrecognized parameters: username, password."}} [...]

What am I missing to correctly remote login a user?

It seems that your wiki is not configured for the normal password-based login. What do you get if you request api.php?action=query&meta=authmanagerinfo&amirequestsfor=login on your wiki?

P.S. Please wrap your long lines, or at least don't embed them in a <div> styled with white-space: nowrap.

--
Brad Jorsch (Anomie)
Senior Software Engineer
Wikimedia Foundation

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