A fork of oauth2-rs
curl
version 0.3.0
and url version 1.1.1
.As an example, follow the example here: ```rust extern crate rustc_serialize; extern crate oauth-api;
use rustcserialize::json; use std::fs::File; use std::io::Read; /* Secrets.json sample contents: { "clientid": "abcde", "clientsecret": "efgab", "authurl": "https://github.com/login/oauth/authorize", "tokenurl": "https://github.com/login/oauth/accesstoken" } */ let mut f = File::open("secrets.json").unwrap(); let mut readstr = String::new(); let _ = f.readtostring(&mut readstr); let sec : Secret = json::decode(&read_str).unwrap();
let mut conf = oauth2::Config::new( &sec.clientid, &sec.clientsecret, &sec.authurl, &sec.tokenurl ); conf.scopes = vec!["repo".toowned()]; let url = conf.authorizeurl("v0.0.1 gitbot".to_owned()); println!("please visit this url: {}", url);
let mut usercode = String::new(); let _ = std::io::stdin().readline(&mut usercode).unwrap(); usercode.pop(); let tok = conf.exchange(usercode).unwrap(); println!("access code is: {}", tok.accesstoken); ```