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 duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const 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
Auto Trait Implementations§
impl Freeze for CobbleProfile
impl RefUnwindSafe for CobbleProfile
impl Send for CobbleProfile
impl Sync for CobbleProfile
impl Unpin for CobbleProfile
impl UnwindSafe for CobbleProfile
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
Mutably borrows from an owned value. Read more