88
99 "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
1010 "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/files"
11+ "golang.org/x/oauth2"
1112)
1213
1314type DropboxWatcher struct {
@@ -30,9 +31,11 @@ type DropboxObject struct {
3031
3132type DropboxConfiguration struct {
3233 Debug Bool `json:"debug"`
33- Token string `json:"token"`
34+ JToken string `json:"token"`
3435 ClientId string `json:"client_id"`
3536 ClientSecret string `json:"client_secret"`
37+
38+ token * oauth2.Token
3639}
3740
3841func newDropboxWatcher (dir string , interval time.Duration ) (Watcher , error ) {
@@ -62,12 +65,16 @@ func (w *DropboxWatcher) SetConfig(m map[string]string) error {
6265 return err
6366 }
6467
65- if config .Token == "" {
68+ if config .JToken == "" {
6669 return fmt .Errorf ("token not specified" )
6770 }
6871 w .config = & config
6972
70- fmt .Printf ("%v" , config )
73+ tok := & oauth2.Token {}
74+ if err := json .Unmarshal ([]byte (config .JToken ), tok ); err != nil {
75+ return err
76+ }
77+ w .config .token = tok
7178 return nil
7279}
7380
@@ -161,14 +168,8 @@ func (w *DropboxWatcher) enumerateFiles(prefix string, callback func(object *Dro
161168 }
162169
163170 config := dropbox.Config {
164- Token : w .config .Token ,
165- LogLevel : logLevel ,
166- Logger : nil ,
167- AsMemberID : "" ,
168- Domain : "" ,
169- Client : nil ,
170- HeaderGenerator : nil ,
171- URLGenerator : nil ,
171+ Token : w .config .token .AccessToken ,
172+ LogLevel : logLevel ,
172173 }
173174 dbx := files .New (config )
174175 arg := files .NewListFolderArg (prefix )
0 commit comments