Archived
1
0
Go (golang) client library for the Dropbox core and Datastore API with support for uploading and downloading encrypted files. !!! deprecated !!!
This repository has been archived on 2021-02-07. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
2021-02-07 15:02:09 +01:00
.travis.yml Add travis file 2014-07-28 21:31:12 +02:00
crypto.go Make Entry.Size and ChunkUploadResponse.Offset be int64 - fixes #19 2015-08-03 21:03:46 +01:00
datastores_changes.go Fix typos 2014-07-12 20:06:22 +02:00
datastores_parser_test.go Add support for the datastore API (early beta) 2014-03-23 18:58:53 +01:00
datastores_parser.go Add support for the datastore API (early beta) 2014-03-23 18:58:53 +01:00
datastores_requests.go Make compatible with go 1.1 2014-07-19 15:36:35 +01:00
datastores_test.go Fix typos 2014-07-12 20:06:22 +02:00
datastores.go Add Delete method to Datastore (Fixes #13) 2015-02-19 20:18:33 +01:00
dropbox_test.go Make Entry.Size and ChunkUploadResponse.Offset be int64 - fixes #19 2015-08-03 21:03:46 +01:00
dropbox.go Remove extra / in Metadata request 2016-04-24 11:09:33 +01:00
LICENSE Initial commit 2014-02-19 14:12:56 -08:00
README.md Deprecate the v1 API 2021-02-07 15:02:09 +01:00

dropbox

Go client library for the Dropbox core and Datastore API with support for uploading and downloading encrypted files.

Support of the Datastore API should be considered as a beta version.

NB this module is for the v1 API which is due to be turned off on 28 June 2017. For the v2 API dropbox have made a a new go SDK themselves.

Prerequisite

To use this library, you must have a valid client ID (app key) and client secret (app secret) provided by Dropbox.
To register a new client application, please visit https://www.dropbox.com/developers/apps/create

Installation

This library depends on the oauth2 package, it can be installed with the go get command:

$ go get golang.org/x/oauth2

This package can be installed with the go get command:

$ go get github.com/stacktic/dropbox

Examples

This simple 4-step example will show you how to create a folder:

package main

import (
    "dropbox"
    "fmt"
)

func main() {
    var err error
    var db *dropbox.Dropbox

    var clientid, clientsecret string
    var token string

    clientid = "xxxxx"
    clientsecret = "yyyyy"
    token = "zzzz"

    // 1. Create a new dropbox object.
    db = dropbox.NewDropbox()

    // 2. Provide your clientid and clientsecret (see prerequisite).
    db.SetAppInfo(clientid, clientsecret)

    // 3. Provide the user token.
    db.SetAccessToken(token)

    // 4. Send your commands.
    // In this example, you will create a new folder named "demo".
    folder := "demo"
    if _, err = db.CreateFolder(folder); err != nil {
        fmt.Printf("Error creating folder %s: %s\n", folder, err)
    } else {
        fmt.Printf("Folder %s successfully created\n", folder)
    }
}

If you do not know the user token, you can replace step 3 by a call to the Auth method:

    // This method will ask the user to visit an URL and paste the generated code.
    if err = db.Auth(); err != nil {
        fmt.Println(err)
        return
    }
    // You can now retrieve the token if you want.
    token = db.AccessToken()

If you want a more complete example, please check the following project: https://github.com/stacktic/dbox.

Documentation

API documentation can be found here: http://godoc.org/github.com/stacktic/dropbox.