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: String
Client ID.
client_secret: String
Client secret.
redirect_uri: Option<String>
Redirect URI.
Methods
impl<P: Provider> Client<P>
[src]
fn new(client_id: String,
client_secret: String,
redirect_uri: Option<String>)
-> Self
client_secret: String,
redirect_uri: Option<String>)
-> Self
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")) );
fn auth_uri(&self,
scope: Option<&str>,
state: Option<&str>)
-> Result<Url, ClientError>
scope: Option<&str>,
state: Option<&str>)
-> Result<Url, ClientError>
Returns an authorization endpoint URI to direct the user to.
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 );
fn request_token(&self,
http_client: &Client,
code: &str)
-> Result<P::Token, ClientError>
http_client: &Client,
code: &str)
-> Result<P::Token, ClientError>
Requests an access token using an authorization code.
impl<P: Provider> Client<P> where P::Token: Token<Refresh>
[src]
fn refresh_token(&self,
http_client: &Client,
token: P::Token,
scope: Option<&str>)
-> Result<P::Token, ClientError>
http_client: &Client,
token: P::Token,
scope: Option<&str>)
-> Result<P::Token, ClientError>
Refreshes an access token.
See RFC 6749, section 6.
fn ensure_token(&self,
http_client: &Client,
token: P::Token)
-> Result<P::Token, ClientError>
http_client: &Client,
token: P::Token)
-> Result<P::Token, ClientError>
Ensures an access token is valid by refreshing it if necessary.
Trait Implementations
impl<P: Debug + Provider> Debug for Client<P>
[src]
impl<P: Clone + Provider> Clone for Client<P>
[src]
fn clone(&self) -> Client<P>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<P: PartialEq + Provider> PartialEq for Client<P>
[src]
fn eq(&self, __arg_0: &Client<P>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Client<P>) -> bool
This method tests for !=
.