Skip to content

Commit

Permalink
feat(auth): open verification url automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Feb 27, 2015
1 parent 1f655b4 commit 515e128
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ rustc-serialize = "*"
[dev-dependencies]
getopts = "*"
yup-hyper-mock = "*"

open = "*"
11 changes: 10 additions & 1 deletion examples/auth.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#![feature(env, collections)]
#![feature(env, collections, old_io, std_misc)]
extern crate "yup-oauth2" as oauth2;
extern crate "yup-hyper-mock" as mock;
extern crate hyper;
extern crate chrono;
extern crate getopts;
extern crate open;

use chrono::{Local};
use getopts::{HasArg,Options,Occur,Fail};
use std::env;
use std::time::Duration;
use std::old_io::timer::sleep;


fn usage(program: &str, opts: &Options, err: Option<Fail>) {
if err.is_some() {
Expand Down Expand Up @@ -55,6 +59,11 @@ fn main() {
You have time until {} to do that.
Do not terminate the program until you deny or grant access !",
pi.user_code, pi.verification_url, pi.expires_at.with_timezone(&Local));
let delay = Duration::seconds(5);
println!("Browser opens automatically in {} seconds", delay);
sleep(delay);
open::that(&pi.verification_url).ok();
println!("DONE - waiting for authorization ...");
}
}

Expand Down

0 comments on commit 515e128

Please sign in to comment.