add with_provider to construct clients with complex providers

This commit is contained in:
Matthew Scheirer 2017-08-18 21:08:44 -04:00
parent 179532e061
commit f44a638568
1 changed files with 14 additions and 4 deletions

View File

@ -46,11 +46,21 @@ impl<P: Provider> Client<P> {
/// );
/// ```
pub fn new(client_id: String, client_secret: String, redirect_uri: Option<String>) -> Self {
Client::with_provider(client_id, client_secret, P::default(), redirect_uri)
}
/// Creates a client with a given Provider. Use when the provider needs non-default Initialization.
pub fn with_provider(
client_id: String,
client_secret: String,
provider: P,
redirect_uri: Option<String>
) -> Self {
Client {
client_id: client_id,
client_secret: client_secret,
redirect_uri: redirect_uri,
provider: P::default(),
client_id,
client_secret,
redirect_uri,
provider
}
}