Struct inth_oauth2_async::client::Client [−][src]
pub struct Client<P> { pub provider: P, pub client_id: String, pub client_secret: String, pub redirect_uri: Option<String>, }
Expand description
OAuth 2.0 client.
Fields
provider: P
OAuth provider.
client_id: String
Client ID.
client_secret: String
Client secret.
redirect_uri: Option<String>
Redirect URI.
Implementations
Creates a client.
Examples
use inth_oauth2_async::Client; use inth_oauth2_async::provider::google::Installed; let client = Client::new( Installed, String::from("CLIENT_ID"), String::from("CLIENT_SECRET"), Some(String::from("urn:ietf:wg:oauth:2.0:oob")), );
Returns an authorization endpoint URI to direct the user to.
Examples
use inth_oauth2_async::Client; use inth_oauth2_async::provider::google::Installed; let client = Client::new( Installed, String::from("CLIENT_ID"), String::from("CLIENT_SECRET"), Some(String::from("urn:ietf:wg:oauth:2.0:oob")), ); let auth_uri = client.auth_uri( Some("https://www.googleapis.com/auth/userinfo.email"), None, );
pub async fn request_token(
&self,
http_client: &impl HttpClient,
code: &str
) -> Result<P::Token, ClientError>
pub async fn request_token(
&self,
http_client: &impl HttpClient,
code: &str
) -> Result<P::Token, ClientError>
Requests an access token using an authorization code.
pub async fn refresh_token(
&self,
http_client: &impl HttpClient,
token: P::Token,
scope: Option<&str>
) -> Result<P::Token, ClientError>
pub async fn refresh_token(
&self,
http_client: &impl HttpClient,
token: P::Token,
scope: Option<&str>
) -> Result<P::Token, ClientError>
Refreshes an access token.
See RFC 6749, section 6.
pub async fn ensure_token(
&self,
http_client: &impl HttpClient,
token: P::Token
) -> Result<P::Token, ClientError>
pub async fn ensure_token(
&self,
http_client: &impl HttpClient,
token: P::Token
) -> Result<P::Token, ClientError>
Ensures an access token is valid by refreshing it if necessary.
Trait Implementations
Auto Trait Implementations
impl<P> RefUnwindSafe for Client<P> where
P: RefUnwindSafe,
impl<P> UnwindSafe for Client<P> where
P: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
pub fn vzip(self) -> V