summaryrefslogtreecommitdiff
path: root/src/strava.rs
blob: 11501843090febbe517fea694fe12d6165449dc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use std::io::Read;
use reqwest;
use std::fs::File;

pub fn read_file<S: AsRef<str>>(path: S) -> String {
    let mut f = File::open(path.as_ref()).unwrap();
    let mut contents = String::new();
    f.read_to_string(&mut contents).unwrap();
    contents
}

pub fn token() -> String {
    read_file("access_token.local").trim().to_string()
}

pub fn run() {
    let token = token();
    println!("got token {}", token);
    let client = reqwest::Client::new();
    let uri = "https://www.strava.com/api/v3/athlete/activities";
    let req = client.get(uri).bearer_auth(token);
    println!("Request: {:?}", req);
    let mut res = req.send().unwrap();
    println!("{:?}", res);
    println!("Content: {}", res.text().unwrap());
}