cartographer/src/main.rs

37 lines
894 B
Rust
Raw Normal View History

2024-09-11 01:34:47 -07:00
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(())
}