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§
Sourcefn oauth_config(&self) -> &OAuthProviderConfig
fn oauth_config(&self) -> &OAuthProviderConfig
Configuração do provedor (endpoints, client_id, escopos, etc.).
Sourcefn app_handle(&self) -> &AppHandle
fn app_handle(&self) -> &AppHandle
Handle da aplicação, necessário para acessar o secrets.db.
Provided Methods§
Sourcefn is_authenticated(&self) -> Result<bool, AppError>
fn is_authenticated(&self) -> Result<bool, AppError>
Verifica se existe um token salvo para este provedor.
Sourcefn 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 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.
Sourcefn 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 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.