Skip to content

Instantly share code, notes, and snippets.

View ywegel's full-sized avatar
🍕

Yannick W. ywegel

🍕
  • Quartett mobile
  • Munich, Germany
View GitHub Profile
@ywegel
ywegel / main.rs
Created March 31, 2024 21:41
Integrating token manager with axum
pub type SharedTokenManager = Arc<Mutex<TokenManager>>;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
...
let shared_token_manager = {
let manager = TokenManager::new(&config.google_application_credentials)
.context("Failed to create token manager")?;
SharedTokenManager::new(Mutex::new(manager))
@ywegel
ywegel / fcm.rs
Created March 31, 2024 21:34
Sending fcm message
// DISCLAIMER: This code is provided as is without any warranties. It's primarily for learning and informational purposes.
// The author does not guarantee that the code is fit for any particular purpose and will not be responsible for any damage or loss resulting from the use of this code.
// The author does not assume liability for the code.
use crate::error::ResponseError;
use anyhow::anyhow;
use serde_json::json;
use crate::config::Config;
use reqwest::Client;
@ywegel
ywegel / oauth_token_manager.rs
Last active March 31, 2024 22:06
oauth_token_manager.rs
// DISCLAIMER: This code is provided as is without any warranties. It's primarily for learning and informational purposes.
// The author does not guarantee that the code is fit for any particular purpose and will not be responsible for any damage or loss resulting from the use of this code.
// The author does not assume liability for the code.
use anyhow::Result;
use std::time::{Duration, SystemTime};
use jsonwebtoken::{encode, EncodingKey, Header};
use reqwest::Client;
use serde_json::json;