pub struct Request { /* private fields */ }Expand description
Represents a request to the Fetch API Key Zulip endpoint.
Allows third-party applications to use a username-password authentication method.
See https://zulip.readthedocs.io/en/latest/production/authentication-methods.html#json-web-tokens-jwt.
Implementations§
Source§impl Request
impl Request
Sourcepub fn create(
algo: Algorithm,
key: &EncodingKey,
email: &Email,
password: &Password,
) -> Result<Self>
pub fn create( algo: Algorithm, key: &EncodingKey, email: &Email, password: &Password, ) -> Result<Self>
Creates a signed JWT token for authenticating the fetch_api_key request.
§Parameters
algo: JWT algorithm set in/etc/zulip/settings.pyfor the shared secretkey: JWT shared secret set in/etc/zulip/settings.py
The key argument should be constructed from the shared secret based on the algorithm.
§Example
use zulip_api::fetch_api_key::{Email, Password, Request};
use zulip_api::jwt;
// if HMAC-SHA256 (`HS256`) is set in `settings.py`
let algo = jwt::Algorithm::HS256;
let key = jwt::EncodingKey::from_base64_secret("MWFlMTgyZjg3NzM1MzMyYmUxNDEwYWMyM2RlMDRkNzRlOWIwNmI4Mjc2YjQwMmZmYWMzNjllNTA5ZThiN2I0Mg==").unwrap();
let email = Email::new("user@example.dev");
let password = Password::new("super_secret_password");
let _req = Request::create(algo, &key, &email, &password).unwrap();See https://zulip.readthedocs.io/en/latest/production/authentication-methods.html#json-web-tokens-jwt.
Source§impl Request
impl Request
Sourcepub fn username(&self) -> &str
pub fn username(&self) -> &str
Gets the Request username.
The username to fetch an API key using the fetch_api_key request.
See https://zulip.readthedocs.io/en/latest/production/authentication-methods.html#json-web-tokens-jwt.
Sourcepub fn set_username(&mut self, val: String)
pub fn set_username(&mut self, val: String)
Sets the Request username.
The username to fetch an API key using the fetch_api_key request.
See https://zulip.readthedocs.io/en/latest/production/authentication-methods.html#json-web-tokens-jwt.
Sourcepub fn with_username(self, val: String) -> Self
pub fn with_username(self, val: String) -> Self
Builder function that sets the Request username.
The username to fetch an API key using the fetch_api_key request.
See https://zulip.readthedocs.io/en/latest/production/authentication-methods.html#json-web-tokens-jwt.
Sourcepub fn password(&self) -> &str
pub fn password(&self) -> &str
Gets the Request password.
The user password to fetch an API key using the fetch_api_key request.
See https://zulip.readthedocs.io/en/latest/production/authentication-methods.html#json-web-tokens-jwt.
Sourcepub fn set_password(&mut self, val: String)
pub fn set_password(&mut self, val: String)
Sets the Request password.
The user password to fetch an API key using the fetch_api_key request.
See https://zulip.readthedocs.io/en/latest/production/authentication-methods.html#json-web-tokens-jwt.
Sourcepub fn with_password(self, val: String) -> Self
pub fn with_password(self, val: String) -> Self
Builder function that sets the Request password.
The user password to fetch an API key using the fetch_api_key request.
See https://zulip.readthedocs.io/en/latest/production/authentication-methods.html#json-web-tokens-jwt.
Sourcepub fn token(&self) -> &str
pub fn token(&self) -> &str
Gets the Request token.
The JWT token used to authenticate the fetch_api_key request.
See https://zulip.readthedocs.io/en/latest/production/authentication-methods.html#json-web-tokens-jwt.
Sourcepub fn set_token(&mut self, val: String)
pub fn set_token(&mut self, val: String)
Sets the Request token.
The JWT token used to authenticate the fetch_api_key request.
See https://zulip.readthedocs.io/en/latest/production/authentication-methods.html#json-web-tokens-jwt.
Sourcepub fn with_token(self, val: String) -> Self
pub fn with_token(self, val: String) -> Self
Builder function that sets the Request token.
The JWT token used to authenticate the fetch_api_key request.
See https://zulip.readthedocs.io/en/latest/production/authentication-methods.html#json-web-tokens-jwt.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Request
impl<'de> Deserialize<'de> for Request
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Request
impl StructuralPartialEq for Request
Auto Trait Implementations§
impl Freeze for Request
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnsafeUnpin for Request
impl UnwindSafe for Request
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.