Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sy-ofb-python-sdk

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sy-ofb-python-sdk

A Python interface for interacting with Microsoft's OneDrive.

  • 0.1.1
  • PyPI
  • Socket score

Maintainers
1

OFB Python SDK

The ofb-python-sdk provides a Python interface for interacting with Microsoft's OneDrive. It simplifies the process of authenticating, uploading, downloading, and managing files on OneDrive through a simple and intuitive API. This SDK is particularly useful for developers who need to integrate OneDrive functionalities within their Python applications efficiently.

Features

  • Authentication with OAuth2
  • Upload files to OneDrive (supports both small and large files)
  • Download files from OneDrive
  • Create and manage folders
  • Delete files and folders
  • Handle file conflicts with customizable behavior
  • Rich progress bar integration for file uploads

Installation

Install ofb-python-sdk using pip:

pip install sy-ofb-python-sdk

Usage

To start using the SDK, you'll first need to import the Client class from the package.

from ofb_python_sdk import Client

Setup

Initialize the client with your application credentials:

client = Client(
    client_id="your_client_id",
    client_secret="your_client_secret",
    refresh_token="your_refresh_token",
    redirect_uri="your_redirect_uri",
)

Upload a File

file_path = "/path/to/your/file"
file_data = open(file_path, "rb").read()
remote_path = "/path/to/onedrive/destination/file.txt"

try:
    response = client.upload_file(file_data, remote_path)
    print("Upload successful:", response.status_code)
except Exception as e:
    print("Upload failed:", e)

Download a File

remote_path = "/path/to/onedrive/file.txt"

try:
    file_data = client.download_file(remote_path)
    with open("downloaded_file.txt", "wb") as file:
        file.write(file_data)
    print("Download successful")
except Exception as e:
    print("Download failed:", e)

Create a Folder

folder_path = "/new/folder"

try:
    response = client.create_folder(folder_path)
    print("Folder creation successful:", response.status_code)
except Exception as e:
    print("Folder creation failed:", e)

Delete a File

remote_path = "/path/to/delete/file.txt"

try:
    response = client.delete_file(remote_path)
    print("Deletion successful:", response.status_code)
except Exception as e:
    print("Deletion failed:", e)

Search a File

keyword = "sometext"

try:
    result: list = client.search_files(keyword)
    print("Search successful:", result)
except Exception as e:
    print("Search failed:", e)

Contributing

Contributions are welcome! Please read the CONTRIBUTING.md for guidelines on how to contribute to this project.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you need assistance or encounter any bugs, please open an issue on the project's GitHub issues page.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc