Skip to main content

nominal_api/conjure/objects/authorization/
get_access_token_request.rs

1/// We accept an OIDC ID token issued by a trusted identity provider as proof of authentication.
2/// The ID token is validated and exchanged for a Nominal access token.
3/// This ID token should generally be short lived since it is fungible with a Nominal access token
4/// via this endpoint. An access token, if provider, is used to get user information from the OIDC
5/// userinfo endpoint. An org rid should be provided if the user is a member of multiple orgs.
6#[derive(
7    Debug,
8    Clone,
9    conjure_object::serde::Serialize,
10    conjure_object::serde::Deserialize,
11    PartialEq,
12    Eq,
13    PartialOrd,
14    Ord,
15    Hash
16)]
17#[serde(crate = "conjure_object::serde")]
18#[conjure_object::private::staged_builder::staged_builder]
19#[builder(crate = conjure_object::private::staged_builder, update, inline)]
20pub struct GetAccessTokenRequest {
21    #[builder(into)]
22    #[serde(rename = "idToken")]
23    id_token: String,
24    #[builder(default, into)]
25    #[serde(rename = "accessToken", skip_serializing_if = "Option::is_none", default)]
26    access_token: Option<String>,
27    #[builder(default, into)]
28    #[serde(rename = "orgRid", skip_serializing_if = "Option::is_none", default)]
29    org_rid: Option<super::super::authentication::api::OrgRid>,
30}
31impl GetAccessTokenRequest {
32    /// Constructs a new instance of the type.
33    #[inline]
34    pub fn new(id_token: impl Into<String>) -> Self {
35        Self::builder().id_token(id_token).build()
36    }
37    #[inline]
38    pub fn id_token(&self) -> &str {
39        &*self.id_token
40    }
41    #[inline]
42    pub fn access_token(&self) -> Option<&str> {
43        self.access_token.as_ref().map(|o| &**o)
44    }
45    #[inline]
46    pub fn org_rid(&self) -> Option<&super::super::authentication::api::OrgRid> {
47        self.org_rid.as_ref().map(|o| &*o)
48    }
49}