codr

Crates.iocodr
lib.rscodr
version1.1.3
sourcesrc
created_at2023-10-18 10:25:01.315633
updated_at2023-11-28 12:15:36.047257
descriptionA CLI tool for interacting with OneDrive.
homepagehttps://github.com/PromH/codr
repositoryhttps://github.com/PromH/codr
max_upload_size
id1006582
size60,886
HypoFreak (PromH)

documentation

README

codr

Client for OneDrive in Rust or (codr) - A Rust Command line tool for interacting with OneDrive.

Usage

codr is a simple client that requires your own Microsoft OAuth2 credentials (see here for official instructions.) in order to function properly.

Once the credentials have been obtained, they can then be supplied to codr through a variety of means (see the Example Commands).

Installing

# Via Cargo
cargo install codr

How to obtain Microsoft OAuth2 Credentials

The following steps outline how these credentials can be obtained.

  • Register a Web application with:
    • A Redirect URI of http://localhost:<REDIRECT_PORT><REDIRECT_ENDPOINT>
      • <REDIRECT_PORT> defaults to 8080
      • <REDIRECT_ENDPOINT> defaults to /redirect
    • The supported account type: Accounts in any organizational directory and personal Microsoft accounts
  • In the left menu select Overview. Copy the Application (client) ID as the MSGRAPH_CLIENT_ID.
  • In the left menu select Certificates & secrets and add a new client secret. Copy the secret value as MSGRAPH_CLIENT_SECRET.
  • In the left menu select API permissions and add a permission then select Microsoft Graph and Delegated permissions. Now add the Files.Read permission (and other permissions as necessary).

Example Commands

# Help commands
codr -h
codr get -h
codr get drive-item -h
codr get drive-item-children -h
codr create sharing-links -h

# Example commands (using command options)
codr -i my-msgraph-client-id -s my-msgraph-client-secret get drive-item path/to/folder
codr -i my-msgraph-client-id -s my-msgraph-client-secret get drive-item-children path/to/folder
codr -i my-msgraph-client-id -s my-msgraph-client-secret create sharing-links path/to/folder/file embed

# Example commands (using config.yaml file)
codr -c config.yaml get drive-item path/to/folder
codr -c config.yaml get drive-item-children path/to/folder
codr -c config.yaml create sharing-links path/to/folder/file embed

# Example commands (using environment variable)
MSGRAPH_CLIENT_ID=my-msgraph-client-id
MSGRAPH_CLIENT_SECRET=my-msgraph-client-secret
codr get drive-item path/to/folder
codr get drive-item-children path/to/folder
codr create sharing-links path/to/folder/file embed

Example Config File Contents

msgraph_client_id: insert-client-id-here
msgraph_client_secret: insert-client-secret-here

Notes

[!WARNING] This is my first Rust project so use with caution...

Commit count: 81

cargo fmt