cartographer/src/main.rs
2024-09-11 01:57:45 -07:00

36 lines
894 B
Rust

use reqwest::header;
use reqwest::Error;
use std::env;
static APP_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"),);
static TOKEN: &str = env!("CANVAS_SECRET");
async fn get_request() -> Result<(), reqwest::Error> {
let mut headers = header::HeaderMap::new();
headers.insert(
header::AUTHORIZATION,
format!("Bearer {}", TOKEN).parse().unwrap(),
);
let client = reqwest::Client::builder()
.user_agent(APP_USER_AGENT)
.default_headers(headers)
.build()?;
let response = client
.get("https://ucsb.instructure.com/api/v1/courses")
.send()
.await?;
println!("Status: {}", response.status());
let body = response.text().await?;
println!("Body:\n{}", body);
Ok(())
}
#[tokio::main]
async fn main() -> Result<(), Error> {
get_request().await?;
Ok(())
}