r/matrixprotocol • u/dettus_Xx_ • Nov 15 '25
Reference Implementation for msc3824 login?
Hello!
So...I want to write my own Matrix Client.
(Yadda yadda yadda... SDK... Bla bla bla bla bla...)
And I must say, that the documentation leaves A LOT to be desired.
My biggest hurdle at the moment is the SSO Login.
The server I am trying to log in to offers me those Flows:
{"flows":[{"type":"m.login.sso","org.matrix.msc3824.delegated_oidc_compatibility":true},{"type":"m.login.token"}]}
Other servers offered me a redirectURL.
Thus far, I was able to open those in a browser, log in, and ended up at a dead-end website with a URL that included the loginToken=znxv,zxcv which i so desperately needed.
How do I do it here?
Is there a "clean" way to get to the token?
Has anyone ever written a reference implementation in Python or with curl?
1
u/imbev Nov 15 '25
Hi! You need to specify a redirect_uri that your client can retrieve info from. This may involve a custom url scheme, configured in a platform-dependent way.
https://spec.matrix.org/v1.16/client-server-api/#oauth-20-api
1
u/dettus_Xx_ Nov 15 '25
Yes... So... I tried that.
I am sending this to the "registration_endpoint":
`client={` `"application_type":"native",` `"client_name":"helloworld",` `"client_uri":"http://localhost",` `"token_endpoint_auth_method":"none",` `"response_types":["code"],` `"redirect_uris":["http://localhost/callback"],` `"grant_types":[` `"authorization_code",` `"refresh_token",` `"urn:ietf:params:oauth:grant-type:token-exchange"` `]` `}`According to the "spec" https://spec.matrix.org/v1.16/client-server-api/#client-registration I should be getting a client id, but the server keeps sending me
{"error":"invalid_request","error_description":"The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed."}I do not think that this is the right approach.
I WISH there was some sort of reference Implementation.1
u/imbev Nov 15 '25
Here is an example request body from Element Web:
{ "client_name": "Element", "client_uri": "https://app.element.io", "response_types": [ "code" ], "grant_types": [ "authorization_code", "refresh_token" ], "redirect_uris": [ "https://app.element.io/?no_universal_links=true" ], "id_token_signed_response_alg": "RS256", "token_endpoint_auth_method": "none", "application_type": "web", "logo_uri": "https://app.element.io/vector-icons/1024.png" }What if you replace your client-specific values with Element's defaults as a test?
1
u/dettus_Xx_ Nov 16 '25 edited Nov 16 '25
Alright!
With the input from u/imbev, I was able to cobble together the following code (Use at your own risk)
AGAIN: I wish they would have put this kind of code somewhere near the matrix client "specs".