Skip to main content

OAuthGameSource

Trait OAuthGameSource 

Source
pub trait OAuthGameSource: GameSource {
    // Required methods
    fn oauth_config(&self) -> &OAuthProviderConfig;
    fn app_handle(&self) -> &AppHandle;

    // Provided methods
    fn is_authenticated(&self) -> Result<bool, AppError> { ... }
    fn ensure_valid_token<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<String, AppError>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait { ... }
    fn login<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), AppError>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait { ... }
    fn logout(&self) -> Result<(), AppError> { ... }
}
Expand description

Extensão de GameSource para fontes que dependem de login OAuth2 (biblioteca remota da conta do usuário).

Required Methods§

Source

fn oauth_config(&self) -> &OAuthProviderConfig

Configuração do provedor (endpoints, client_id, escopos, etc.).

Source

fn app_handle(&self) -> &AppHandle

Handle da aplicação, necessário para acessar o secrets.db.

Provided Methods§

Source

fn is_authenticated(&self) -> Result<bool, AppError>

Verifica se existe um token salvo para este provedor.

Source

fn ensure_valid_token<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<String, AppError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

Retorna um access_token válido, renovando via refresh_token se necessário.

Source

fn login<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), AppError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

Executa o fluxo completo de login: abre o navegador, aguarda o callback local, valida o state (CSRF) e troca o code por um token, que é salvo automaticamente.

Source

fn logout(&self) -> Result<(), AppError>

Remove o token salvo (logout).

Implementors§