Skip to main content

OAuthEnvironment

Trait OAuthEnvironment 

Source
pub trait OAuthEnvironment:
    Send
    + Sync
    + 'static {
    type Token: TokenEndpoint + Send + Sync;

    // Required methods
    fn token_endpoint(&self, url: &str) -> Self::Token;
    fn get(
        &self,
        url: &str,
    ) -> impl Future<Output = Result<Fetched, EnvironmentError>> + Send;
    fn post_json(
        &self,
        url: &str,
        body: &str,
    ) -> impl Future<Output = Result<Fetched, EnvironmentError>> + Send;
    fn authorize(
        &self,
        authorization_url: &str,
    ) -> impl Future<Output = Result<AuthorizationCallback, EnvironmentError>> + Send;
}
Expand description

The outside world, as the authorization flow sees it.

Required Associated Types§

Source

type Token: TokenEndpoint + Send + Sync

Where authorization codes are redeemed, bound to one endpoint.

Required Methods§

Source

fn token_endpoint(&self, url: &str) -> Self::Token

A token endpoint at url.

Source

fn get( &self, url: &str, ) -> impl Future<Output = Result<Fetched, EnvironmentError>> + Send

GETs url without following redirects.

§Errors

EnvironmentError::Unavailable when no response was read.

Source

fn post_json( &self, url: &str, body: &str, ) -> impl Future<Output = Result<Fetched, EnvironmentError>> + Send

POSTs body to url as application/json.

§Errors

EnvironmentError::Unavailable when no response was read.

Source

fn authorize( &self, authorization_url: &str, ) -> impl Future<Output = Result<AuthorizationCallback, EnvironmentError>> + Send

Sends the user to authorization_url and returns where they came back.

A browser adapter opens the URL and waits for the loopback redirect; a headless one asks an authorization server that approves by itself and reads the Location it answers with.

§Errors

EnvironmentError::Declined when no callback arrived.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§