pub struct Oauth { /* private fields */ }
Expand description
OAuth 2.0 Authentication
This struct represents the OAuth authentication process for Minecraft, specifically designed for use with custom Azure applications. It is used to authenticate a user and obtain a token that can be used to launch Minecraft.
Implementations§
Source§impl Oauth
impl Oauth
Sourcepub fn new(client_id: &str, port: Option<u16>) -> Self
pub fn new(client_id: &str, port: Option<u16>) -> Self
Initializes a new Oauth
instance.
This method sets up the OAuth authentication process by constructing the authorization URL and storing the client ID and port for later use.
§Arguments
client_id
- The client ID obtained from the Minecraft authentication service.port
- An optional port number for the local server. Defaults to 8000 if not provided.
§Returns
Self
- A new instance ofOauth
configured with the provided client ID and port.
Sourcepub fn url(&self) -> &str
pub fn url(&self) -> &str
Retrieves the authorization URL.
This method returns the URL that the user needs to visit to authorize the application.
§Returns
&str
- The authorization URL.
Sourcepub async fn launch(
&self,
bedrock_relm: bool,
client_secret: &str,
) -> Result<CustomAuthData, Box<dyn Error>>
pub async fn launch( &self, bedrock_relm: bool, client_secret: &str, ) -> Result<CustomAuthData, Box<dyn Error>>
Launches Minecraft using the OAuth authentication process.
This method completes the OAuth authentication process by launching a local server to receive the authorization code, exchanging it for an access token, and then using 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.client_secret
- The client secret obtained from the Minecraft authentication service.
§Returns
Result<CustomAuthData, Box<dyn std::error::Error>>
- A result containing the authentication data or an error if the process fails.