Skip to content

Commit 1d3771a

Browse files
fivebangerfivebanger
andauthored
Get token with client (#1385)
Co-authored-by: fivebanger <[email protected]>
1 parent f96f36c commit 1d3771a

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222

2323
### Added
2424

25+
- [core] Add `get_token_with_client_id()` to get a token for a specific client ID
2526
- [core] Add `login` (mobile) and `auth_token` retrieval via login5
2627
- [core] Add `OS` and `os_version` to `config.rs`
2728
- [discovery] Added a new MDNS/DNS-SD backend which connects to Avahi via D-Bus.

core/src/token.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,20 @@ impl TokenProvider {
5858
})
5959
}
6060

61+
// Not all combinations of scopes and client ID are allowed.
62+
// Depending on the client ID currently used, the function may return an error for specific scopes.
63+
// In this case get_token_with_client_id() can be used, where an appropriate client ID can be provided.
6164
// scopes must be comma-separated
6265
pub async fn get_token(&self, scopes: &str) -> Result<Token, Error> {
6366
let client_id = self.session().client_id();
67+
self.get_token_with_client_id(scopes, &client_id).await
68+
}
69+
70+
pub async fn get_token_with_client_id(
71+
&self,
72+
scopes: &str,
73+
client_id: &str,
74+
) -> Result<Token, Error> {
6475
if client_id.is_empty() {
6576
return Err(Error::invalid_argument("Client ID cannot be empty"));
6677
}

0 commit comments

Comments
 (0)