ruma_federation_api/openid/get_openid_userinfo.rs
1//! `GET /_matrix/federation/*/openid/userinfo`
2//!
3//! Exchange an OpenID access token for information about the user who generated the token.
4
5pub mod v1 {
6 //! `/v1/` ([spec])
7 //!
8 //! [spec]: https://spec.matrix.org/latest/server-server-api/#get_matrixfederationv1openiduserinfo
9
10 use ruma_common::{
11 OwnedUserId,
12 api::{auth_scheme::NoAuthentication, request, response},
13 metadata,
14 };
15
16 metadata! {
17 method: GET,
18 rate_limited: false,
19 authentication: NoAuthentication,
20 path: "/_matrix/federation/v1/openid/userinfo",
21 }
22
23 /// Request type for the `get_openid_userinfo` endpoint.
24 #[request]
25 pub struct Request {
26 /// The OpenID access token to get information about the owner for.
27 #[ruma_api(query)]
28 pub access_token: String,
29 }
30
31 /// Response type for the `get_openid_userinfo` endpoint.
32 #[response]
33 pub struct Response {
34 /// The Matrix User ID who generated the token.
35 pub sub: OwnedUserId,
36 }
37
38 impl Request {
39 /// Creates a new `Request` with the given access token.
40 pub fn new(access_token: String) -> Self {
41 Self { access_token }
42 }
43 }
44
45 impl Response {
46 /// Creates a new `Response` with the given user id.
47 pub fn new(sub: OwnedUserId) -> Self {
48 Self { sub }
49 }
50 }
51}