Android SDK for the Kloudless API
Requirements:
- AndroidStudio 4.0.1 or equivalent
- You need to have registered as a Kloudless app at https://developers.kloudless.com. You should have an App key and API Key.
Note: The SDK is designed to work with Java 1.8 or above.
- Open the project KTester in Android Studio
- Fill in the values for fileId and linkId
- Build and Run the MainActivity.java
- Once running, you can test the functionalities of the API without errors.
Copy this code from the example app from lines 46 through 131 into your application to mirror how this example app authorizes users: https://github.com/Kloudless/kloudless-android/blob/master/KTester/app/src/main/java/com/kloudless/ktester/MainActivity.java#L46
You can add the code to your own activity rather than the onCreate
of
a separate activity.
Then, make the following changes:
- The example app uses android.support.customtabs.CustomTabsIntent to handle the OAuth 2.0 flow to Kloudless and stores the access token and account ID at Kloudless.bearerToken and Kloudless.accountId.
- To authorize users from your own app, first register a Redirect URI
scheme in the Kloudless developer portal
App Details
page (e.g. ktester://kloudless/callback), replacingktester
with your app's package suffix as shown here, or any other scheme. - Add an Intent Filter to the AndroidManifest.xml that matches the Redirect URI scheme, similar to the one the example app sets up here.
- Initialize your own CustomTabsIntent Builder and launch the authorization URL with your own button action, as shown in the example code in MainActivity.
- Once your app retrieves the token, make an API call to verify it and retrieve the account ID as shown in the example app.
- You can now successfully make requests to the Kloudless API with the bearer token and account ID.
Note: You will need to add androidx.browser:browser:1.2.0
to your
module's build.gradle file and add the android.permission.INTERNET
to your
AndroidManifest.xml
file.
- Verify that Maven is a valid repository in your Project's build.gradle
- Add
com.kloudless:kloudless-java:1.0.4
to your module's build.gradle file. - Under
compileOptions
verifysourceCompatibility
andtargetCompatibility
asJavaVersion.VERSION_1_8
. - Under
packagingOptions
excludeMETA-INF/LICENSE
- Now you can import
com.kloudless.Kloudless
to any file!
See the Kloudless API Docs for the official documentation.
You can obtain an App ID at the Developer Portal.
Step 1. Click the Link Account button to connect an account.
Step 2. Click the additional buttons to test Kloudless API requests.
To make your own requests with the Java SDK you will need to create an AsyncTask as seen in MainActivity.java.
To authenticate with your own Application ID or Client ID, please follow the steps above.