pub struct DeviceCode { /* private fields */ }
Expand description
Device Code Authentication
This struct represents the device code authentication process for Minecraft, specifically designed for use with custom Azure applications. It is used to authenticate a device and obtain a token that can be used to launch Minecraft.
Implementations§
Source§impl DeviceCode
impl DeviceCode
Sourcepub fn new(client_id: &str) -> impl AsyncSendSync<Result<Self, Error>>
pub fn new(client_id: &str) -> impl AsyncSendSync<Result<Self, Error>>
Initializes a new DeviceCode
instance.
This method starts the device code authentication process by making an asynchronous request
to the authentication server. It returns a future that resolves to a Result
containing the
DeviceCode
instance on success or an error if the request fails.
§Arguments
client_id
- The client ID obtained from the Minecraft authentication service.
§Returns
impl async_trait_alias::AsyncSendSync<Result<Self, reqwest::Error>>
- A future that resolves to aResult
containing theDeviceCode
instance or an error.
Sourcepub fn preinfo(&self) -> (&str, &str, u32, &str)
pub fn preinfo(&self) -> (&str, &str, u32, &str)
Provides pre-launch information.
This method returns a tuple containing the verification URL, the message to display to the user, the expiration time of the device code, and the user code. This information is useful for guiding the user through the device code authentication process.
§Returns
(&str, &str, u32, &str)
- A tuple containing the verification URL, the message, the expiration time, and the user code.
Sourcepub async fn launch(
&self,
bedrock_relm: bool,
) -> Result<CustomAuthData, Box<dyn Error>>
pub async fn launch( &self, bedrock_relm: bool, ) -> Result<CustomAuthData, Box<dyn Error>>
Launches Minecraft using the device code authentication process.
This method completes the device code authentication process by authenticating the device and obtaining a token. It then uses this token to launch Minecraft. The method supports both Bedrock Edition and Java Edition of Minecraft.
§Arguments
bedrock_relm
- A boolean indicating whether to launch the Bedrock Edition of Minecraft.
§Returns
Result<CustomAuthData, Box<dyn std::error::Error>>
- A result containing the authentication data or an error if the process fails.