Struct inth_oauth2::client::Client

source ·
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::Client;
use inth_oauth2::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.

See RFC 6749, section 3.1.

Examples
use inth_oauth2::Client;
use inth_oauth2::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,
);

Requests an access token using an authorization code.

See RFC 6749, section 4.1.3.

Refreshes an access token.

See RFC 6749, section 6.

Ensures an access token is valid by refreshing it if necessary.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.