Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3394209
D12765.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D12765.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
Sun, Dec 1, 6:15 PM (19 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2605776
Default Alt Text
D12765.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