java保存access token,使用access_token java将文件上载到google驱动器

我有java服务器端的网站。

当用户提交表单时,我希望应用程序从表单输入中获取文本,并将其作为.txt文件上载到

我的

谷歌驱动器帐户。

我可以将文本从客户端传输到服务器端。

我可以从文本创建一个文件。

我无法使用有效的access_令牌获取文件并将其上载到我的google驱动器,因为我不知道如何执行post请求。

我试过的却没有运气:

File file = new File ("omer.txt");

CloseableHttpClient client = HttpClients.createDefault();

HttpPost httpPost = new HttpPost("https://www.googleapis.com/upload/drive/v3/files?uploadType=media");

//add reuqest header

con.setRequestMethod("POST");

httpPost.setHeader("Content-Type", "text/plain");

httpPost.setHeader("Authorization", "Bearer " + access_token);

//execute the post request and upload the file to my google drive using the access token

//execute the post request and upload the file to my google drive using the access token

那么:如何使用有效的access_令牌将txt文件上载到google驱动器?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值