This project provide a Java version of Amazon Cloud Drive API from REST version.
Maven/Gradle
https://jitpack.io/#umjammer/ACD-JAPI
There are two ways to create Configure
instance.
- Copy
ACD-JAPI.conf.sample
toACD-JAPI.conf
and load byConfigure.load(File configureFile)
. - Create a
Configure
instance and update it.
name, client_id, client_secret is necessary!
owner is required when use Property
operation.
Follow HowTo section to get access_token
and refresh_token
redirect_uri #string after authenticated, redirect the result to this url.
name (*) #string configure file name
client_secret (*) #string secret profile password
autoRefresh #boolean auto refresh token when expired.(token lifetime is 3600)
owner #string this field is required only on `Property` operation.
client_id (*) #string secret profile id
token_type (*) #string API token type (it should be `bearer`, it'll auto refresh when refresh token)
access_token (**) #string API access token.
writable #boolean is Amazon Cloud Drive writable.
refresh_token (**) #string API refresh token.
autoConfigureUpdate #boolean auto refresh configure file.
(*) is necessary.
(**) for all API operation.
Sample run Class is example.MainSampleClass
To start using it, you should have amazon account and request a secret profile then add to CloudDrive whitelist. Please visit Getting Started for more detail.
- Add Security Profile
- Add your security profile to Whitelist
- Login to https://www.amazon.com/ap/oa?client_id=replace_this_with_your_client_id&scope=clouddrive%3Aread%20clouddrive%3Awrite&response_type=code&redirect_uri=http://localhost and get return param code from return url. Example: if the return url is http://localhost/?code=ANdNAVhyhqirUelHGEHA&scope=clouddrive%3Aread+clouddrive%3Awrite , then the code is ANdNAVhyhqirUelHGEHA.
- Setting
Configure
by load from file (Configure.load(File configureFile)
), or create aConfigure
instance and update it. - Use
ACDSession.getACDSessionByCode(Configure configure, String code)
to get firstACDSession
, usegetToken()
to get token or it'll save to file ifautoConfigureUpdate
istrue
. - Use
ACDSession.getACDSessionByToken(Configure configure, ACDToken acdToken)
to getACDSession
when you have previous token. - Once you have
access_token
andrefresh_token
, save it at configure file, it can be loaded byConfigure.load(File configureFile)
, and update the configure to file byConfigure.save()
. If theautoConfigureUpdate
andautoRefresh
field in configure file is set as true, it'll auto refresh token when expired and auto write config to file.
Yes
Have token--------> Follow 4. and 6. to get ACDSession
|
No |--> Follow 1. ~ 5. to get ACDSession and token
ACD
provide friendly method to operate those API.
You should create a ACDSession
instance for all operation.
The raw APIs are at org.yetiz.lib.acd.api
package.
Please fork and send Pull Request
Respect the formatting rules: Ident with 1 tab Use a 140 chars line max length Don't use * imports
Support log4j (using slf4j)