Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33330487
D12765.1768881845.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D12765.1768881845.diff
View Options
diff --git a/services/tunnelbroker/src/notifs/fcm/token.rs b/services/tunnelbroker/src/notifs/fcm/token.rs
--- a/services/tunnelbroker/src/notifs/fcm/token.rs
+++ b/services/tunnelbroker/src/notifs/fcm/token.rs
@@ -9,6 +9,13 @@
use tokio::sync::RwLock;
use tracing::debug;
+#[derive(Debug, Clone, Deserialize)]
+struct FCMAccessTokenResponse {
+ access_token: String,
+ token_type: String,
+ expires_in: u64,
+}
+
#[derive(Debug, Clone, Deserialize)]
struct FCMAccessToken {
access_token: String,
@@ -65,4 +72,21 @@
let token = jsonwebtoken::encode(&header, &payload, &encoding_key)?;
Ok(token)
}
+
+ async fn get_fcm_access_token(
+ &self,
+ jwt_token: String,
+ ) -> Result<FCMAccessTokenResponse, Error> {
+ let response = reqwest::Client::new()
+ .post(self.config.token_uri.clone())
+ .form(&[
+ ("grant_type", "urn:ietf:params:oauth:grant-type:jwt-bearer"),
+ ("assertion", &jwt_token),
+ ])
+ .send()
+ .await?;
+
+ let access_token = response.json::<FCMAccessTokenResponse>().await?;
+ Ok(access_token)
+ }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jan 20, 4:04 AM (6 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5959304
Default Alt Text
D12765.1768881845.diff (1 KB)
Attached To
Mode
D12765: [Tunnelbroker] implement requesting FCM access token using OAuth 2.0
Attached
Detach File
Event Timeline
Log In to Comment