Socket
Socket
Sign inDemoInstall

github.com/dalaomai/go-onedrive

Package Overview
Dependencies
2
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/dalaomai/go-onedrive

Package api is the root of the packages used to access Microsoft OneDrive. Within api there exist also testing utilities. Note that versioning and stability is strictly not communicated through Go modules. Go modules are used only for dependency management. As a user, you should always locally vendor any API(s) that your code relies upon in this module.


Version published

Readme

Source

go-onedrive

Go Build CodeQL Scan Go Report Card Go Reference License: GPL v3 Donate

go-onedrive is a Golang client library for accessing the Microsoft OneDrive REST API.

This project is inspired by a few open-source projects, especially the go-github project from Google.

Currently, go-onedrive requires Golang version 1.15 or greater. go-onedrive tracks Golang version support policy. I'll do my best not to break older versions of Golang if I don't have to, but due to tooling constraints, I don't always test older versions.

Getting Started

Module support was introduced in Go 1.15. Starting from Go 1.16, module-aware mode is enabled by default. Hence, I'll assume the module-aware mode is enabled when using this library.

In the go.mod file, please make sure the correct package with the correct version is used.

...

require (
	github.com/goh-chunlin/go-onedrive v1.1.0
	...
)

The current latest version should be v1.1.0 (updated on 8th May 2021, as shown on the Releases page).

In other go source files, you can then import the go-onedrive library as follows.

import "github.com/goh-chunlin/go-onedrive/onedrive"

Construct a new OneDrive client, then use the various services on the client to access different parts of the OneDrive API. For example:

ctx := context.Background()
ts := oauth2.StaticTokenSource(
	&oauth2.Token{AccessToken: "..."},
)
tc := oauth2.NewClient(ctx, ts)

client := onedrive.NewClient(tc)

// list all OneDrive drives for the current logged in user
drives, err := onedrive.Drives.List(ctx)

NOTE: Using the context package, one can easily pass cancelation signals and deadlines to various services of the client for handling a request. In case there is no context available, then context.Background() can be used as a starting point.

Authentication

The go-onedrive library does not directly handle authentication. Instead, when creating a new client, pass an http.Client that can handle authentication for you. The easiest and recommended way to do this is using the oauth2 library.

Note that when using an authenticated Client, all calls made by the client will include the specified OAuth token. Therefore, authenticated clients should almost never be shared between different users.

See the oauth2 docs for complete instructions on using that library.

Contributing

This library is being initially developed as a library for my personal project as listed below.

Hence, API methods will likely be implemented in the order that they are needed by my personal project. However, I still welcome you to contribute to this project to support the following features.

  • General
    • Async job to track progress
    • Search
  • Drives
    • Get default drive
    • Get individual drive
    • List all available drives
  • Folders
    • Create
    • Copy
    • Delete
    • List children (items)
    • Move
    • Rename
    • Create share link to a folder and its content
    • List share links of a folder
  • Items
    • Get individual item
    • Copy
    • Delete
    • Move
    • Rename
    • Create share link to an item
    • List share links of an item
    • Upload simple item size < 4MB
    • Upload and then replace with item size < 4MB

Sensei Projects

Special thanks go to the following projects for providing useful references which help me in the development of this library.

License

This library is distributed under the GPL-3.0 License found in the LICENSE file.

FAQs

Last updated on 19 Jun 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc