Struct inth_oauth2::client::Client [] [src]

pub struct Client<P> {
    pub provider: P,
    pub client_id: String,
    pub client_secret: String,
    pub redirect_uri: Option<String>,
}

OAuth 2.0 client.

Fields

OAuth provider.

Client ID.

Client secret.

Redirect URI.

Methods

impl<P: Provider> Client<P>
[src]

[src]

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")),
);

[src]

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,
);

[src]

Requests an access token using an authorization code.

See RFC 6749, section 4.1.3.

impl<P> Client<P> where
    P: Provider,
    P::Token: Token<Refresh>, 
[src]

[src]

Refreshes an access token.

See RFC 6749, section 6.

[src]

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

Trait Implementations

impl<P: Debug> Debug for Client<P>
[src]

[src]

Formats the value using the given formatter.

impl<P: Clone> Clone for Client<P>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<P: PartialEq> PartialEq for Client<P>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl<P: Eq> Eq for Client<P>
[src]