Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Missing access token" in Client.display_name in some instances (gnome.modular.im) #488

Closed
danigm opened this issue Feb 10, 2022 · 3 comments

Comments

@danigm
Copy link
Contributor

danigm commented Feb 10, 2022

The call to Client.display_name always return a 401 if the server requires authentication for profiles.

let user = "example";
let client = Client::new("https://gnome.modular.im").unwrap();
client.login(user, "password", None, None).await.unwrap();

let result = client.display_name().await;
assert!(result.is_err());

Describe the solution you'd like
It should be possible to provide the access token to this call.

Additional context
This is failing for gnome.modular.im instance, Fractal cannot get the user display name because of this.

https://gitlab.gnome.org/GNOME/fractal/-/issues/934

@jplatte
Copy link
Collaborator

jplatte commented Feb 10, 2022

EDIT: Oh, I guess the method you're talking about doesn't have a RequestConfig parameter, making this impossible at least when using the convenient way to get display names. What could work is setting force_auth in the default request config, but then you'll send the access token for every request that shouldn't need it.

Unfortunately the Matrix spec doesn't really have the concept of "may require authentication on some servers". Until that is implemented, you can use RequestConfig to force the access token to be sent for relevant endpoints: https://matrix-org.github.io/matrix-rust-sdk/matrix_sdk/config/struct.RequestConfig.html#method.force_auth

@danigm
Copy link
Contributor Author

danigm commented Feb 10, 2022

Thanks for the reply, I've added the force_auth to the login in fractal, but it looks like this fails with the default login.

This fixes the issue when restoring a previous session, but in the call to client.login I'm getting an error:

tried to force authentication but no access token was provided

@jplatte
Copy link
Collaborator

jplatte commented Feb 10, 2022

Sounds like force_auth isn't really supported as a default option then. Let's wait to see what poljar thinks about this issue.

danigm added a commit to danigm/matrix-rust-sdk that referenced this issue Feb 11, 2022
It looks like the force_auth is working correctly when restoring the
session, but it's not working with the call to client.login, so it
cannot be used.

The access_token is not available in the login query, so if the option
force_auth is set, this call will fail always. This patch just ignores
the force_auth if there's no session, so any query will work when
force_auth is true.

This change fixes the problem reported here:

matrix-org#488
danigm added a commit to danigm/matrix-rust-sdk that referenced this issue Feb 11, 2022
It looks like the force_auth is working correctly when restoring the
session, but it's not working with the call to client.login, so it
cannot be used.

The access_token is not available in the login query, so if the option
force_auth is set, this call will fail always. This patch just ignores
the force_auth if there's no session, so any query will work when
force_auth is true.

Fix matrix-org#488
@poljar poljar closed this as completed in 4b5aae1 Feb 11, 2022
danigm added a commit to danigm/matrix-rust-sdk that referenced this issue Feb 11, 2022
It looks like the force_auth is working correctly when restoring the
session, but it's not working with the call to client.login, so it
cannot be used.

The access_token is not available in the login query, so if the option
force_auth is set, this call will fail always. This patch just ignores
the force_auth if there's no session, so any query will work when
force_auth is true.

Fix matrix-org#488
jsparber pushed a commit to jsparber/matrix-rust-sdk that referenced this issue Feb 11, 2022
It looks like the force_auth is working correctly when restoring the
session, but it's not working with the call to client.login, so it
cannot be used.

The access_token is not available in the login query, so if the option
force_auth is set, this call will fail always. This patch just ignores
the force_auth if there's no session, so any query will work when
force_auth is true.

Fix matrix-org#488
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants