summaryrefslogtreecommitdiff
path: root/src/strava.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/strava.rs')
-rw-r--r--src/strava.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/strava.rs b/src/strava.rs
new file mode 100644
index 0000000..7d6c2a2
--- /dev/null
+++ b/src/strava.rs
@@ -0,0 +1,27 @@
+use std::io::{self, Write, 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());
+}