/// Implements the FIDL TokenManager.Authorize method using an AuthProvider that does not
/// support IoT ID.
Implements the FIDL TokenManager.Authorize method using an AuthProvider that does not
support IoT ID.
Implements the FIDL TokenManager . Authorize method using an AuthProvider that does not support IoT ID .
async fn handle_authorize<'a>(
        &'a self,
        context: &'a TokenManagerContext,
        app_config: AppConfig,
        user_profile_id: Option<String>,
        _app_scopes: Vec<String>,
    ) -> TokenManagerResult<UserProfileInfo> {
        let auth_provider_type = &app_config.auth_provider_type;
        let auth_provider_proxy = await!(self.get_auth_provider_proxy(auth_provider_type))?;
        let (ui_context_client_end, ui_context_server_end) =
            create_endpoints().token_manager_status(Status::UnknownError)?;
        context
            .auth_ui_context_provider
            .get_authentication_ui_context(ui_context_server_end)
            .token_manager_status(Status::InvalidAuthContext)?;
        let (status, credential, user_profile_info) = await!(auth_provider_proxy
            .get_persistent_credential(
                Some(ui_context_client_end),
                user_profile_id.as_ref().map(|x| &**x),
            ))
        .map_err(|err| {
            self.discard_auth_provider_proxy(auth_provider_type);
            TokenManagerError::new(Status::AuthProviderServerError).with_cause(err)
        })?;
        match (credential, user_profile_info) {
            (Some(credential), Some(user_profile_info)) => {
                let db_value = CredentialValue::new(
                    app_config.auth_provider_type,
                    user_profile_info.id.clone(),
                    credential,
                    None,
                )
                .map_err(|_| Status::AuthProviderServerError)?;
                self.token_store.lock().add_credential(db_value)?;
                Ok(*user_profile_info)
            }
            _ => Err(TokenManagerError::from(status)),
        }
    }
async fn handle_authorize < ' a > ( & ' a self , context : & ' a TokenManagerContext , app_config : AppConfig , user_profile_id : Option < String > , _app_scopes : Vec < String > , ) -> TokenManagerResult < UserProfileInfo > { let auth_provider_type = & app_config . auth_provider_type ; let auth_provider_proxy = await ! ( self get_auth_provider_proxy ( auth_provider_type ) ) ? ; let ( ui_context_client_end , ui_context_server_end ) = create_endpoints ( ) . token_manager_status ( Status :: UnknownError ) ? ; context . auth_ui_context_provider . get_authentication_ui_context ( ui_context_server_end ) . token_manager_status ( Status :: InvalidAuthContext ) ? ; let ( status , credential , user_profile_info ) = await ! ( auth_provider_proxy get_persistent_credential ( Some ( ui_context_client_end ) user_profile_id as_ref ( ) map ( x x ) ) ) . map_err ( | err | { self . discard_auth_provider_proxy ( auth_provider_type ) ; TokenManagerError :: new ( Status :: AuthProviderServerError ) . with_cause ( err ) } ) ? ; match ( credential , user_profile_info ) { ( Some ( credential ) , Some ( user_profile_info ) ) => { let db_value = CredentialValue :: new ( app_config . auth_provider_type , user_profile_info . id . clone ( ) , credential , None , ) . map_err ( | _ | Status :: AuthProviderServerError ) ? ; self . token_store . lock ( ) . add_credential ( db_value ) ? ; Ok ( * user_profile_info ) } _ => Err ( TokenManagerError :: from ( status ) ) , } }
Implements the FIDL TokenManager.Authorize method using an AuthProvider that does not
support IoT ID.
Implements the FIDL TokenManager . Authorize method using an AuthProvider that does not support IoT ID .
&'a self
context
&'a TokenManagerContext
app_config
AppConfig
user_profile_id
Option<String>
_app_scopes
Vec<String>