一段时间过去了,但现在 Dropbox 将让您生成公共访问令牌并在您的代码中使用它
所以是的,有一种方法可以允许永久访问 Dropbox API。我们需要从应用程序设置(保管箱控制台)生成访问令牌并使用它。这是 Dropbox 所说的:
通过生成访问令牌,您将能够为您自己的帐户进行 API 调用,而无需通过授权流程。要获取其他用户的访问令牌,请使用标准 OAuth 流程。
用暗语:
AndroidAuthSession session = buildSession();
mApi = new DropboxAPI<AndroidAuthSession>(session);
private AndroidAuthSession buildSession() {
AppKeyPair appKeyPair = new AppKeyPair(APP_KEY, APP_SECRET);
AndroidAuthSession session = new AndroidAuthSession(appKeyPair, ACCESS_TOKEN);
// I guess then you just have to instantiate a DropboxAPI object and you're good to go without the startAuthentication()... endAuthentication() etc.
return session;
}
and here we go just use the mApi to do whatever you want