azalea-rs / azalea

A collection of Rust crates for making Minecraft bots, clients, and tools.
https://azalea.matdoes.dev
MIT License
361 stars 48 forks source link

Auth Customization Options #159

Closed AS1100K closed 2 weeks ago

AS1100K commented 2 months ago

What this PR adds?

This PR addresses and closes the issue #130. It introduces two new functions in azalea_client::Account:

This PR will allow the developer, to customize the client_id and scope, or use the nintendo switch one. Also, some other functions in auth.rs like refresh_ms_auth_token, get_ms_link_code, interactive_get_ms_auth_token, etc. are modified and takes some extra parameters now. See the changes in auth.rs for more information.

Backwards Compatibility?

The existing functions microsoft and with_microsoft_access_token will maintain their current functionality. However, their implementations have been refactored to depend on the new functions microsoft_with_custom_client_id_and_scope and with_microsoft_access_token_and_custom_client_id_and_scope to avoid code duplication and facilitate easier maintenance.

1zun4 commented 2 months ago

This is great, but you are missing two important options:

If you are using your own ClientID, these changes are also mandatory. Otherwise this option is useless. I saw that you added a custom scope, but then removed it as it was apparently not needed? What is the reason for this? - https://github.com/azalea-rs/azalea/pull/159/commits/d2bb6f4b6d1350b5973cde7c0eeed2570c0dfe7f

AS1100K commented 2 months ago

I saw that you added a custom scope, but then removed it as it was apparently not needed? What is the reason for this? - d2bb6f4

I removed the custom scope because that time i thought, that modifying permissions might not be required but rethinking it now, i realize that how can this be useful. Like you liquidboune client_id only works with other scope i.e. not the default one. Also, may be you can take extra permissions and integrate your bot with that.

I will add custom scope and RpsTicket format and commit the changes

veronoicc commented 1 month ago

I just looked trough it an saw a lot of parameters with &'static str, and to my knowledge getting somethink as an &'static is not really possible (unless with a hardcoded str in this case) without leaking memory. Maybe using a non 'static str here is better?

veronoicc commented 1 month ago

Meant fields in the AuthOps struct mb