torhve / weechat-matrix-protocol-script

A WeeChat script in Lua that implements the matrix.org chat protocol
349 stars 52 forks source link

Update the login API JSON #116

Closed trmendes closed 6 years ago

trmendes commented 6 years ago

This change is based on a JSON riot.im sends to the server to login into it. The json riot.im sends it is different from the official JSON API documentation. So I have found this doc where there is a proposal for a change:

https://docs.google.com/document/d/1-6ZSSW5YvCGhVFDyD2QExAUAdpCWjccvJT5xiyTTG2Y/ edit#

There is another link where the docs are updated: https://kamax.io/matrix/api/client_server/unstable.html# post-matrix-client-r0-login

Fixes #113

torhve commented 6 years ago

I merged this but then I couldn't login to my homeserver anymore. I changed

-            ["address"]=user,
+           ["user"]=user,

and now I can, does that change also work for the probably newer synapse server at matrix.org?

trmendes commented 6 years ago

@torhve Are you connection to matrix.org too?

I made a change here from ["user"]=user instead of ["address"] but it does not work. When I change it I get an INVALID_PASSWORD

The change I made to the JSON file we send is based on the riot.im web client JSON.

When I went to the matrix channel to ask about why the official documents were different from the way riot.im was doing they a guy told me the api was changed but they didn't had the time to update it :(...they told me the old way was not working anymore but there was a guy there saying that the old way was still working so I'm not sure about the right way to write this JSON yet. :(

What do you think? Did you see any other document that give us some idea about how to it right?

dbkr commented 6 years ago

It looks like what's going on here is that the PR hardcodes the identifier to an email address, so logging in with an email would work but not with a user ID. With the new API, you need to say what type of identifier you're logging in with.

trmendes commented 6 years ago

@dbkr :)...that makes a lot of sense

trmendes commented 6 years ago

@torhve What would be the best way of checking if the user is typing an ID or an email using your script?

torhve commented 6 years ago

Should probably just look in the userfield for : or @ or something, and change the post fields accordingly. You want to try to do this, would be appreciated.

trmendes commented 6 years ago

@torhve Yes....that would be an easy way of doing it. I was wondering if Matrix accept @ as a valid char for their user ID names. @dbkr Do you know something about it?