mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2026-02-23 15:50:00 +01:00
Make DeviceFlowDelegate::present_user_code return a Future.
This is to allow for implementations to use async code. The returned Future will be awaited before polling for the token begins.
This commit is contained in:
@@ -80,19 +80,26 @@ pub trait DeviceFlowDelegate: Send + Sync {
|
||||
/// along with the `verification_uri`.
|
||||
/// # Notes
|
||||
/// * Will be called exactly once, provided we didn't abort during `request_code` phase.
|
||||
fn present_user_code(&self, pi: &DeviceAuthResponse) {
|
||||
println!(
|
||||
"Please enter {} at {} and grant access to this application",
|
||||
pi.user_code, pi.verification_uri
|
||||
);
|
||||
println!("Do not close this application until you either denied or granted access.");
|
||||
println!(
|
||||
"You have time until {}.",
|
||||
pi.expires_at.with_timezone(&Local)
|
||||
);
|
||||
fn present_user_code<'a>(
|
||||
&'a self,
|
||||
device_auth_resp: &'a DeviceAuthResponse,
|
||||
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>> {
|
||||
Box::pin(present_user_code(device_auth_resp))
|
||||
}
|
||||
}
|
||||
|
||||
async fn present_user_code(device_auth_resp: &DeviceAuthResponse) {
|
||||
println!(
|
||||
"Please enter {} at {} and grant access to this application",
|
||||
device_auth_resp.user_code, device_auth_resp.verification_uri
|
||||
);
|
||||
println!("Do not close this application until you either denied or granted access.");
|
||||
println!(
|
||||
"You have time until {}.",
|
||||
device_auth_resp.expires_at.with_timezone(&Local)
|
||||
);
|
||||
}
|
||||
|
||||
/// InstalledFlowDelegate methods are called when an installed flow needs to ask
|
||||
/// the application what to do in certain cases.
|
||||
pub trait InstalledFlowDelegate: Send + Sync {
|
||||
|
||||
Reference in New Issue
Block a user