Struct cobble_core::profile::CobbleProfile
source · pub struct CobbleProfile {
pub uuid: Uuid,
pub profile_id: String,
pub player_name: String,
pub microsoft_refresh_token: String,
pub minecraft_token: String,
pub minecraft_token_exp: OffsetDateTime,
}
Available on crate feature
auth
only.Expand description
A profile for Minecraft online mode.
// See the oauth2 crate for information to create a Microsoft Application for `MS_GRAPH_ID`.
let code_info = CobbleProfile::setup_authentication("<MS_GRAPH_ID>".to_string()).await?;
// Print and URL
println!("URL: {}", &code_info.verification_url());
println!("CODE: {}", &code_info.user_code());
// Waits until authentication is done
let profile: CobbleProfile = CobbleProfile::authenticate(code_info).await?;
Fields§
§uuid: Uuid
Profile UUID
.
profile_id: String
Minecraft profile ID
player_name: String
Minecraft player name
microsoft_refresh_token: String
Microsoft refresh token
minecraft_token: String
Minecraft token
minecraft_token_exp: OffsetDateTime
Minecraft token expiration
Implementations§
source§impl CobbleProfile
impl CobbleProfile
sourcepub fn access_token(&self) -> String
pub fn access_token(&self) -> String
Gets the Minecraft access token
sourcepub async fn setup_authentication(
client_id: String
) -> AuthResult<DeviceCodeInfo>
pub async fn setup_authentication(
client_id: String
) -> AuthResult<DeviceCodeInfo>
Setup the authentication process. Returns a struct used to retrieve the device code and verification URL. The result of this call is used to finish the authentication.
sourcepub async fn authenticate(info: DeviceCodeInfo) -> AuthResult<Self>
pub async fn authenticate(info: DeviceCodeInfo) -> AuthResult<Self>
Finish authentication by polling microsoft for the token. Subsequently authenticates with XBoxLive, XBoxLiveSecurity and Minecraft.
sourcepub async fn refresh(&mut self, client_id: String) -> AuthResult<()>
pub async fn refresh(&mut self, client_id: String) -> AuthResult<()>
Refreshes the Minecraft access token.
Trait Implementations§
source§impl Clone for CobbleProfile
impl Clone for CobbleProfile
source§fn clone(&self) -> CobbleProfile
fn clone(&self) -> CobbleProfile
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for CobbleProfile
impl Debug for CobbleProfile
source§impl<'de> Deserialize<'de> for CobbleProfile
impl<'de> Deserialize<'de> for CobbleProfile
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>,
Deserialize this value from the given Serde deserializer. Read more