Use TLS in examples
This commit is contained in:
parent
62e8d11cb6
commit
f3906e71d0
|
@ -1,11 +1,19 @@
|
|||
extern crate hyper;
|
||||
extern crate hyper_native_tls;
|
||||
extern crate inth_oauth2;
|
||||
|
||||
use std::io;
|
||||
|
||||
use hyper_native_tls::NativeTlsClient;
|
||||
use hyper::net::HttpsConnector;
|
||||
use inth_oauth2::Client;
|
||||
use inth_oauth2::provider::GitHub;
|
||||
|
||||
fn main() {
|
||||
let tls = NativeTlsClient::new().unwrap();
|
||||
let connector = HttpsConnector::new(tls);
|
||||
let https = hyper::Client::with_connector(connector);
|
||||
|
||||
let client = Client::<GitHub>::new(
|
||||
String::from("01774654cd9a6051e478"),
|
||||
String::from("9f14d16d95d605e715ec1a9aecec220d2565fd5c"),
|
||||
|
@ -18,6 +26,6 @@ fn main() {
|
|||
let mut code = String::new();
|
||||
io::stdin().read_line(&mut code).unwrap();
|
||||
|
||||
let token = client.request_token(&Default::default(), code.trim()).unwrap();
|
||||
let token = client.request_token(&https, code.trim()).unwrap();
|
||||
println!("{:?}", token);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
extern crate hyper;
|
||||
extern crate hyper_native_tls;
|
||||
extern crate inth_oauth2;
|
||||
|
||||
use std::io;
|
||||
|
||||
use hyper_native_tls::NativeTlsClient;
|
||||
use hyper::net::HttpsConnector;
|
||||
use inth_oauth2::Client;
|
||||
use inth_oauth2::provider::google::{Installed, REDIRECT_URI_OOB};
|
||||
|
||||
fn main() {
|
||||
let tls = NativeTlsClient::new().unwrap();
|
||||
let connector = HttpsConnector::new(tls);
|
||||
let https = hyper::Client::with_connector(connector);
|
||||
|
||||
let client = Client::<Installed>::new(
|
||||
String::from("143225766783-ip2d9qv6sdr37276t77luk6f7bhd6bj5.apps.googleusercontent.com"),
|
||||
String::from("3kZ5WomzHFlN2f_XbhkyPd3o"),
|
||||
|
@ -19,11 +27,9 @@ fn main() {
|
|||
let mut code = String::new();
|
||||
io::stdin().read_line(&mut code).unwrap();
|
||||
|
||||
let http_client = Default::default();
|
||||
|
||||
let token = client.request_token(&http_client, code.trim()).unwrap();
|
||||
let token = client.request_token(&https, code.trim()).unwrap();
|
||||
println!("{:?}", token);
|
||||
|
||||
let token = client.refresh_token(&http_client, token, None).unwrap();
|
||||
let token = client.refresh_token(&https, token, None).unwrap();
|
||||
println!("{:?}", token);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
extern crate hyper;
|
||||
extern crate hyper_native_tls;
|
||||
extern crate inth_oauth2;
|
||||
|
||||
use std::io;
|
||||
|
||||
use hyper_native_tls::NativeTlsClient;
|
||||
use hyper::net::HttpsConnector;
|
||||
use inth_oauth2::Client;
|
||||
use inth_oauth2::provider::google::Web;
|
||||
|
||||
fn main() {
|
||||
let tls = NativeTlsClient::new().unwrap();
|
||||
let connector = HttpsConnector::new(tls);
|
||||
let https = hyper::Client::with_connector(connector);
|
||||
|
||||
let client = Client::<Web>::new(
|
||||
String::from("143225766783-0h4h5ktpvhc7kqp6ohbpd2sssqrap57n.apps.googleusercontent.com"),
|
||||
String::from("7Xjn-vRN-8qsz3Zh9zZGkHsM"),
|
||||
|
@ -19,6 +27,6 @@ fn main() {
|
|||
let mut code = String::new();
|
||||
io::stdin().read_line(&mut code).unwrap();
|
||||
|
||||
let token = client.request_token(&Default::default(), code.trim()).unwrap();
|
||||
let token = client.request_token(&https, code.trim()).unwrap();
|
||||
println!("{:?}", token);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
extern crate hyper;
|
||||
extern crate hyper_native_tls;
|
||||
extern crate inth_oauth2;
|
||||
|
||||
use std::io;
|
||||
|
||||
use hyper_native_tls::NativeTlsClient;
|
||||
use hyper::net::HttpsConnector;
|
||||
use inth_oauth2::Client;
|
||||
use inth_oauth2::provider::Imgur;
|
||||
|
||||
fn main() {
|
||||
let tls = NativeTlsClient::new().unwrap();
|
||||
let connector = HttpsConnector::new(tls);
|
||||
let https = hyper::Client::with_connector(connector);
|
||||
|
||||
let client = Client::<Imgur>::new(
|
||||
String::from("505c8ca804230e0"),
|
||||
String::from("c898d8cf28404102752b2119a3a1c6aab49899c8"),
|
||||
|
@ -18,11 +26,9 @@ fn main() {
|
|||
let mut code = String::new();
|
||||
io::stdin().read_line(&mut code).unwrap();
|
||||
|
||||
let http_client = Default::default();
|
||||
|
||||
let token = client.request_token(&http_client, code.trim()).unwrap();
|
||||
let token = client.request_token(&https, code.trim()).unwrap();
|
||||
println!("{:?}", token);
|
||||
|
||||
let token = client.refresh_token(&http_client, token, None).unwrap();
|
||||
let token = client.refresh_token(&https, token, None).unwrap();
|
||||
println!("{:?}", token);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue