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

pub struct Client<P: Provider> {
    pub client_id: String,
    pub client_secret: String,
    pub redirect_uri: Option<String>,
    // some fields omitted
}

OAuth 2.0 client.

Fields

Client ID.

Client secret.

Redirect URI.

Methods

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

Creates a client.

Examples

use inth_oauth2::Client;
use inth_oauth2::provider::google::Installed;

let client = Client::<Installed>::new(
    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::<Installed>::new(
    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.

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

Refreshes an access token.

See RFC 6749, section 6.

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

Trait Implementations

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

Formats the value using the given formatter.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

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

This method tests for !=.

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