pub struct KeycloakClient {
pub inner: BasicClient,
pub config: ClientConfiguration,
pub cache: Arc<Mutex<KeyCache>>,
}Fields§
§inner: BasicClient§config: ClientConfiguration§cache: Arc<Mutex<KeyCache>>Implementations§
Source§impl KeycloakClient
impl KeycloakClient
Sourcepub fn new(config: ClientConfiguration) -> Self
pub fn new(config: ClientConfiguration) -> Self
Examples found in repository?
examples/client.rs (line 8)
5async fn main() -> Result<(), ClientError> {
6 let config = ClientConfiguration::from_env();
7
8 let keycloak_client = KeycloakClient::new(config);
9 let token = match keycloak_client.verify_and_refresh_access_token().await {
10 Ok(token) => token,
11 Err(_) => keycloak_client
12 .authenticate()
13 .await?
14 .access_token()
15 .secret()
16 .clone(),
17 };
18
19 //make requests with the token
20 println!("{}", token);
21
22 Ok(())
23}pub async fn initiate_device_flow( &self, ) -> Result<DeviceAuthorizationResponse<EmptyExtraDeviceAuthorizationFields>, ClientError>
pub fn cache_token( &self, token: &StandardTokenResponse<EmptyExtraTokenFields, BasicTokenType>, ) -> Result<(), ClientError>
pub fn load_cached_token(&self) -> Result<CachedToken, ClientError>
pub async fn poll_for_token( &self, device_auth_response: &DeviceAuthorizationResponse<EmptyExtraDeviceAuthorizationFields>, ) -> Result<StandardTokenResponse<EmptyExtraTokenFields, BasicTokenType>, ClientError>
Sourcepub async fn authenticate(
&self,
) -> Result<StandardTokenResponse<EmptyExtraTokenFields, BasicTokenType>, ClientError>
pub async fn authenticate( &self, ) -> Result<StandardTokenResponse<EmptyExtraTokenFields, BasicTokenType>, ClientError>
Examples found in repository?
examples/client.rs (line 12)
5async fn main() -> Result<(), ClientError> {
6 let config = ClientConfiguration::from_env();
7
8 let keycloak_client = KeycloakClient::new(config);
9 let token = match keycloak_client.verify_and_refresh_access_token().await {
10 Ok(token) => token,
11 Err(_) => keycloak_client
12 .authenticate()
13 .await?
14 .access_token()
15 .secret()
16 .clone(),
17 };
18
19 //make requests with the token
20 println!("{}", token);
21
22 Ok(())
23}Sourcepub async fn verify_access_token(
&self,
token: &str,
) -> Result<TokenData<Claims>, ClientError>
pub async fn verify_access_token( &self, token: &str, ) -> Result<TokenData<Claims>, ClientError>
Verifies the passed access token
Sourcepub async fn verify_and_refresh_access_token(
&self,
) -> Result<String, ClientError>
pub async fn verify_and_refresh_access_token( &self, ) -> Result<String, ClientError>
Examples found in repository?
examples/client.rs (line 9)
5async fn main() -> Result<(), ClientError> {
6 let config = ClientConfiguration::from_env();
7
8 let keycloak_client = KeycloakClient::new(config);
9 let token = match keycloak_client.verify_and_refresh_access_token().await {
10 Ok(token) => token,
11 Err(_) => keycloak_client
12 .authenticate()
13 .await?
14 .access_token()
15 .secret()
16 .clone(),
17 };
18
19 //make requests with the token
20 println!("{}", token);
21
22 Ok(())
23}Auto Trait Implementations§
impl !RefUnwindSafe for KeycloakClient
impl !UnwindSafe for KeycloakClient
impl Freeze for KeycloakClient
impl Send for KeycloakClient
impl Sync for KeycloakClient
impl Unpin for KeycloakClient
impl UnsafeUnpin for KeycloakClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more