6 个稳定版本

1.1.3 2023年11月28日
1.1.1 2023年10月21日
1.1.0 2023年10月18日
1.0.7 2023年10月18日

#108 in 构建工具

Download history 5/week @ 2024-04-02

60 每月下载量

MIT 许可证

71KB
970

codr

Client for OneDrive in Rust 或 (codr) - 用于与 OneDrive 交互的 Rust 命令行工具。

用法

codr 是一个简单的客户端,需要您的 Microsoft OAuth2 凭证(请参阅此处的官方说明)才能正常运行。

获取凭证后,可以通过多种方式将其提供给 codr(请参阅示例命令)。

安装

# Via Cargo
cargo install codr

如何获取 Microsoft OAuth2 凭证

以下步骤概述了如何获取这些凭证。

  • 使用具有
    • Redirect URIWeb 应用程序 https://127.0.0.1:<REDIRECT_PORT><REDIRECT_ENDPOINT>
      • <REDIRECT_PORT> 默认为 8080
      • <REDIRECT_ENDPOINT> 默认为 /redirect
    • 支持的账户类型:任何组织目录中的账户和个人 Microsoft 账户
  • 在左侧菜单中选择 概览。将 应用程序 (客户端) ID 复制为 MSGRAPH_CLIENT_ID
  • 在左侧菜单中选择 证书 & 秘密 并添加一个新的客户端密钥。将密钥值复制为 MSGRAPH_CLIENT_SECRET
  • 在左侧菜单中选择 API 权限 并添加一个权限,然后选择 Microsoft Graph授权权限。现在添加 Files.Read 权限(以及其他必要的权限)。

示例命令

# 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

示例配置文件内容

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

注意

[!警告] 这是我第一个Rust项目,请谨慎使用...

依赖项

~11–31MB
~482K SLoC