Get token with client (#1385)

Co-authored-by: fivebanger <fivebanger@gmx-topmail.de>
This commit is contained in:
fivebanger 2024-10-30 20:24:01 +01:00 committed by GitHub
parent f96f36c064
commit 1d3771a83b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View file

@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- [core] Add `get_token_with_client_id()` to get a token for a specific client ID
- [core] Add `login` (mobile) and `auth_token` retrieval via login5
- [core] Add `OS` and `os_version` to `config.rs`
- [discovery] Added a new MDNS/DNS-SD backend which connects to Avahi via D-Bus.

View file

@ -58,9 +58,20 @@ impl TokenProvider {
})
}
// Not all combinations of scopes and client ID are allowed.
// Depending on the client ID currently used, the function may return an error for specific scopes.
// In this case get_token_with_client_id() can be used, where an appropriate client ID can be provided.
// scopes must be comma-separated
pub async fn get_token(&self, scopes: &str) -> Result<Token, Error> {
let client_id = self.session().client_id();
self.get_token_with_client_id(scopes, &client_id).await
}
pub async fn get_token_with_client_id(
&self,
scopes: &str,
client_id: &str,
) -> Result<Token, Error> {
if client_id.is_empty() {
return Err(Error::invalid_argument("Client ID cannot be empty"));
}