pub fn request<F, S, RE>(
        self,
        http_client: F,
        sleep_fn: S,
        timeout: Option<Duration>,
    ) -> Result<TR, RequestTokenError<RE, DeviceCodeErrorResponse>>
    where
        F: Fn(HttpRequest) -> Result<HttpResponse, RE>,
        S: Fn(Duration),
        RE: Error + 'static,
    {
        // Get the request timeout and starting interval
        let timeout_dt = self.compute_timeout(timeout)?;
        let mut interval = self.dev_auth_resp.interval();

        // Loop while requesting a token.
        loop {
            let now = (*self.time_fn)();
            if now > timeout_dt {
                break Err(RequestTokenError::Other("Device code expired".to_string()));
            }

            match self.process_response(http_client(self.prepare_request()?), interval) {
                DeviceAccessTokenPollResult::ContinueWithNewPollInterval(new_interval) => {
                    interval = new_interval
                }
                DeviceAccessTokenPollResult::Done(res, _) => break res,
            }

            // Sleep here using the provided sleep function.
            sleep_fn(interval);
        }
    }
///
/// Synchronously polls the authorization server for a response, waiting
/// using a user defined sleep function.
///
Synchronously polls the authorization server for a response, waiting
using a user defined sleep function.
Synchronously polls the authorization server for a response waiting using a user defined sleep function .
pub fn request<F, S, RE>(
        self,
        http_client: F,
        sleep_fn: S,
        timeout: Option<Duration>,
    ) -> Result<TR, RequestTokenError<RE, DeviceCodeErrorResponse>>
    where
        F: Fn(HttpRequest) -> Result<HttpResponse, RE>,
        S: Fn(Duration),
        RE: Error + 'static,
    {
        // Get the request timeout and starting interval
        let timeout_dt = self.compute_timeout(timeout)?;
        let mut interval = self.dev_auth_resp.interval();
        // Loop while requesting a token.
        loop {
            let now = (*self.time_fn)();
            if now > timeout_dt {
                break Err(RequestTokenError::Other("Device code expired".to_string()));
            }
            match self.process_response(http_client(self.prepare_request()?), interval) {
                DeviceAccessTokenPollResult::ContinueWithNewPollInterval(new_interval) => {
                    interval = new_interval
                }
                DeviceAccessTokenPollResult::Done(res, _) => break res,
            }
            // Sleep here using the provided sleep function.
            sleep_fn(interval);
        }
    }
pub fn request < F , S , RE > ( self , http_client : F , sleep_fn : S , timeout : Option < Duration > , ) -> Result < TR , RequestTokenError < RE , DeviceCodeErrorResponse > > where F : Fn ( HttpRequest ) -> Result < HttpResponse , RE > , S : Fn ( Duration ) , RE : Error + ' static , { // Get the request timeout and starting interval let timeout_dt = self . compute_timeout ( timeout ) ? ; let mut interval = self . dev_auth_resp . interval ( ) ; // Loop while requesting a token. loop { let now = ( * self . time_fn ) ( ) ; if now > timeout_dt { break Err ( RequestTokenError :: Other ( " " . to_string ( ) ) ) ; } match self . process_response ( http_client ( self . prepare_request ( ) ? ) , interval ) { DeviceAccessTokenPollResult :: ContinueWithNewPollInterval ( new_interval ) => { interval = new_interval } DeviceAccessTokenPollResult :: Done ( res , _ ) => break res , } // Sleep here using the provided sleep function. sleep_fn ( interval ) ; } }
Synchronously polls the authorization server for a response, waiting
using a user defined sleep function.
Synchronously polls the authorization server for a response waiting using a user defined sleep function .
self
http_client
F
sleep_fn
S
timeout
Option<Duration>
self
http_client
F
sleep_fn
S
timeout
Option<Duration>