Try using Dropbox API v2 with Go

As the title suggests, I tried using the Dropbox API.

Go get to get started

``` go get github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/... ```

Sample code for uploading files

It is a process of creating an instance and uploading a file.
import "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
import "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/users"

func main() {
	config := dropbox.Config{
		Token: "<Obtained access token>",
	}
	dbx := users.New(config)

	req := files.NewCommitInfo("<File upload destination>")
	f, _ := os.Open("<The path of the file you want to upload>")
	_, err := dbx.Upload(req, f)
	if err != nil {
		log.Print(err)
		return
	}
}

Get an access token for the Dropbox API

I registered from the following site and got an access token. https://www.dropbox.com/developers

I tried it, but ...

It didn't work. I got the message "missing_scope" and looked it up, but it wasn't authoritative. I added files.content.write to edit the contents of Dropbox files and folders, which has no permissions added by default, and ran it again and it worked.

image.png

Where I got stuck

Obviously, you will need to reissue the access token after adding permissions. Please be careful, too.

Impressions

I would like to create a system that saves the images sent to LINE Bot in Dropbox.

Recommended Posts

Try using Dropbox API v2 with Go
Try slack OAuth authentication with flask (Slack API V2)
Try using the DropBox Core API in Python
Try using PythonTex with Texpad.
Try using S3 object upload and download with AWS SDK for Go v2
Try using matplotlib with PyCharm
Try using the Twitter API
Try to make RESTful API with MVC using Flask 1.0.2
Try using the Twitter API
Try using the PeeringDB 2.0 API
Try implementing perfume with Go
Try using folium with anaconda
Play with YouTube Data API v3 using Google API Python Client
Try using Janus gateway's Admin API
Try using Pleasant's API (python / FastAPI)
Using Lambda with AWS Amplify with Go
Using cgo with the go command
Try using Python argparse's action API
Create API using hug with mod_wsgi
Try using Python's networkx with AtCoder
Try using the Wunderlist API in Python
Try mathematical formulas using Σ with python
Try using the Kraken API in Python
Try implementing XOR with Keras Functional API
Try using the camera with Python's OpenCV
I tried using YOUTUBE Data API V3
Let's try gRPC with Go and Docker
Try using Python with Google Cloud Functions
Generate API spec using GO / Gin gin-swagger
Play with puns using the COTOHA API
Automatic follow-back using streaming api with Tweepy
Try using Tkinter
Tweet regularly with the Go language Twitter API
Try using docker-py
Try using cookiecutter
Python with Go
Try using the BitFlyer Ligntning API in Python
Try using geopandas
Try using conda virtual environment with Jupyter Notebook
Try using Selenium
Try using scipy
[AWS] Try tracing API Gateway + Lambda with X-Ray
Try using pandas.DataFrame
Recent ranking creation using Qiita API with Python
Try using kabu station API of kabu.com Securities
Try using django-swiftbrowser
Try using matplotlib
Try using tf.metrics
Try using PyODE
Try using ChatWork API and Qiita API in Python
[First API] Try to get Qiita articles with Python
Call your own C library with Go using cgo
Try projective transformation of images using OpenCV with Python
Register a ticket with redmine API using python requests
Try to delete tweets in bulk using Twitter API
How to analyze with Google Colaboratory using Kaggle API
Speech file recognition by Google Speech API v2 using Python
Upload to a shared drive with Google Drive API V3
Get tweets with arbitrary keywords using Twitter's Streaming API
Try scraping with Python.
Try using virtualenv (virtualenvwrapper)