You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#Dropbox SDK for Go [UNOFFICIAL][](https://godoc.org/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox)
2
2
3
3
An **UNOFFICIAL** Go SDK for integrating with the Dropbox API v2. Tested with Go 1.5+
4
4
5
5
WARNING: This SDK is **NOT yet official**. What does this mean?
6
6
7
-
* There is no formal Dropbox https://www.dropbox.com/developers/support[support] for this SDK at this point
7
+
* There is no formal Dropbox [support](https://www.dropbox.com/developers/support) for this SDK at this point
8
8
* Bugs may or may not get fixed
9
9
* Not all SDK features may be implemented and implemented features may be buggy or incorrect
10
10
11
11
12
-
=== Uh OK, so why are you releasing this?
12
+
###Uh OK, so why are you releasing this?
13
13
14
14
* the SDK, while unofficial, _is_ usable. See https://github.com/dropbox/dbxcli[dbxcli] for an example application built using the SDK
15
15
* we would like to get feedback from the community and evaluate the level of interest/enthusiasm before investing into official supporting one more SDK
16
16
17
-
== Installation
17
+
##Installation
18
18
19
-
[source,sh]
20
-
----
19
+
```sh
21
20
$ go get github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/...
22
-
----
21
+
```
23
22
24
23
For most applications, you should just import the relevant namespace(s) only. The SDK exports the following sub-packages:
25
24
@@ -31,16 +30,15 @@ For most applications, you should just import the relevant namespace(s) only. Th
31
30
32
31
Additionally, the base `github.com/dropbox/dropbox-sdk-go-unofficial/dropbox` package exports some configuration and helper methods.
33
32
34
-
== Usage
33
+
##Usage
35
34
36
-
First, you need to https://dropbox.com/developers/apps:[register a new "app"] to start making API requests. Once you have created an app, you can either use the SDK via an access token (useful for testing) or via the regular OAuth2 flow (recommended for production).
35
+
First, you need to [register a new "app"](https://dropbox.com/developers/apps) to start making API requests. Once you have created an app, you can either use the SDK via an access token (useful for testing) or via the regular OAuth2 flow (recommended for production).
37
36
38
-
=== Using OAuth token
37
+
###Using OAuth token
39
38
40
39
Once you've created an app, you can get an access token from the app's console. Note that this token will only work for the Dropbox account the token is associated with.
For this, you will need your `APP_KEY` and `APP_SECRET` from the developers console. Your app will then have to take users though the oauth flow, as part of which users will explicitly grant permissions to your app. At the end of this process, users will get a token that the app can then use for subsequent authentication. See https://godoc.org/golang.org/x/oauth2#example-Config[this] for an example of oauth2 flow in Go.
54
+
For this, you will need your `APP_KEY` and `APP_SECRET` from the developers console. Your app will then have to take users though the oauth flow, as part of which users will explicitly grant permissions to your app. At the end of this process, users will get a token that the app can then use for subsequent authentication. See [this](https://godoc.org/golang.org/x/oauth2#example-Config) for an example of oauth2 flow in Go.
57
55
58
56
Once you have the token, usage is same as above.
59
57
60
-
=== Making API calls
58
+
###Making API calls
61
59
62
-
Each Dropbox API takes in a request type and returns a response type. For instance, https://www.dropbox.com/developers/documentation/http/documentation#users-get_account[/users/get_account] takes as input a `GetAccountArg` and returns a `BasicAccount`. The typical pattern for making API calls is:
60
+
Each Dropbox API takes in a request type and returns a response type. For instance, [/users/get_account](https://www.dropbox.com/developers/documentation/http/documentation#users-get_account) takes as input a `GetAccountArg` and returns a `BasicAccount`. The typical pattern for making API calls is:
63
61
64
62
* Instantiate the argument via the `New*` convenience functions in the SDK
65
63
* Invoke the API
66
64
* Process the response (or handle error, as below)
67
65
68
66
Here's an example:
69
67
70
-
[source, go]
71
-
----
68
+
```go
72
69
arg:= users.NewGetAccountArg()
73
70
ifresp, err:= dbx.GetAccount(arg); err != nil {
74
71
return err
75
72
}
76
73
fmt.Printf("Name: %v", resp.Name)
77
-
----
74
+
```
78
75
79
-
=== Error Handling
76
+
###Error Handling
80
77
81
78
As described in the https://www.dropbox.com/developers/documentation/http/documentation#error-handling[API docs], all HTTP errors _except_ 409 are returned as-is to the client (with a helpful text message where possible). In case of a 409, the SDK will return an endpoint-specific error as described in the API. This will be made available as `EndpointError` member in the error.
82
79
83
-
== Note on using the Teams API
80
+
##Note on using the Teams API
84
81
85
82
To use the Team API, you will need to create a Dropbox Business App. The OAuth token from this app will _only_ work for the Team API.
86
83
87
-
Please read the https://www.dropbox.com/developers/documentation/http/teams[API docs] carefully to appropriate secure your apps and tokens when using the Team API.
84
+
Please read the [API docs](https://www.dropbox.com/developers/documentation/http/teams) carefully to appropriate secure your apps and tokens when using the Team API.
88
85
89
-
== Code Generation
86
+
##Code Generation
90
87
91
-
This SDK is automatically generated using the public https://github.com/dropbox/dropbox-api-spec[Dropbox API spec]
92
-
and https://github.com/dropbox/stone[Stone]. See this https://github.com/dropbox/dropbox-sdk-go-unofficial/blob/master/generator/README.asciidoc[README]
88
+
This SDK is automatically generated using the public [Dropbox API spec](https://github.com/dropbox/dropbox-api-spec) and [Stone](https://github.com/dropbox/stone). See this [README](https://github.com/dropbox/dropbox-sdk-go-unofficial/blob/master/generator/README.md)
93
89
for more details on how code is generated.
94
90
95
-
== Caveats
91
+
##Caveats
96
92
97
93
* To re-iterate, this is an **UNOFFICIAL** SDK and thus has no official support from Dropbox
98
-
* Only supports the v2 API. Parts of the v2 API are still in beta, and thus subject to change
99
-
* This SDK itself is in beta, and so interfaces may change at any point
94
+
* Only supports the v2 API. Parts of the v2 API are still in beta, and thus subject to change
95
+
* This SDK itself is in beta, and so interfaces may change at any point
0 commit comments