cuvent / react-native-matrix-sdk

(Inofficial) React Native SDK for Matrix.org
MIT License
25 stars 5 forks source link

Login With Token userID and Homeserver #3

Closed Loewe1000 closed 4 years ago

Loewe1000 commented 4 years ago

Hi,

I would need the possibility to login with token, userID and homeserver instead of username and password, because our implementation of the matrix server works without username and passwords.

If I hardcode token, userID and home server, this works. But is there any method to login with token, id and server with this sdk? This would be great. :)

hannojg commented 4 years ago

This isn't implemented yet. I think one idea would be to have the possibility to pass a Credentials object to the startSession method.

I will look into it, or you could create a PR (quite busy right now) 😊

Loewe1000 commented 4 years ago

Thanks, I will try it with the startSession method.

hannojg commented 4 years ago

Hey @Loewe1000, we have added a setCredentials method yesterday. So, you can call

MatrixSDK.configure(...)
MatrixSDK.setCredentials(...)
MatrixSDK.startSession()

Documentation of set credentials:

    /**
     * When you already obtained the credentials using {@see login}, instead of logging in on e.g. every app start,
     * you can pass the credentials here. This will save you one login request.
     */
    setCredentials(accessToken: string, deviceId: string, userId: string, homeServer: string, refreshToken?: string): void;
hannojg commented 4 years ago

Also on android, there is a method called loginWithToken(username: string, token: string, deviceName: string) it will return an MXCredentials which can be used later on with the procedure I described above. It is not publicly exposed yet.