| Crates.io | msoauth |
| lib.rs | msoauth |
| version | 1.1.1 |
| created_at | 2025-05-23 12:00:28.648526+00 |
| updated_at | 2025-06-29 20:55:28.162227+00 |
| description | A simple Microsoft OAuth2 client |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1686222 |
| size | 68,186 |
MSOAuth is a simple command-line tool for obtaining and refreshing Microsoft OAuth2 tokens.
To install the MSOAuth tool, you'll need to have Rust and Cargo installed on your system. Once you have them, you can build and install the project using:
cargo install --path .
This will create an executable in the target/release directory.
Create a configuration file config.toml located in the msoauth directory within your system's config directory, e.g., ~/.config/msoauth/config.toml. The configuration file should look like this:
client_id = "YOUR_CLIENT_ID"
client_secret = "YOUR_CLIENT_SECRET"
tenant_id = "YOUR_TENANT_ID"
scope = "https://graph.microsoft.com/.default"
To obtain these values:
Application (client) ID and Directory (tenant) ID.Microsoft Graph > Delegated | User.Read or other needed scopes.The MSOAuth tool provides several command-line options:
--print-token: Prints the current access token if it's valid. If the token is expired or close to expiring, it will attempt to refresh it.--refresh: Forces a token refresh.--login: Initiates a device login flow to obtain a new token.--clear-token: Deletes the saved token file.Example usage:
msoauth --login # Start device login flow
msoauth --refresh # Refresh the token if expired
msoauth --print-token # Print current access token (refresh if needed)
msoauth --clear-token # Delete the saved token file
msoauth # Default, try refresh, fallback to login
You can use MSOAuth in your mbsyncrc file with:
PassCmd "msoauth --print-token"
This will ensure that only the token is printed and no other messages interfere with the mbsync operations.
set imap_pass="`msoauth --print-token`"
This project is licensed under the MIT License. See the LICENSE file for more information.