Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
OneDrive SDK for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Nied committed Nov 12, 2015
0 parents commit 26f0db8
Show file tree
Hide file tree
Showing 386 changed files with 27,362 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
*.iml
.idea/

## Directory-based project format:

# User-specific stuff:
.idea/workspace.xml
.idea/tasks.xml
.idea/dictionaries

# Sensitive or high-churn files:
.idea/dataSources.ids
.idea/dataSources.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml

# Gradle:
.idea/gradle.xml
.idea/libraries

# Mongo Explorer plugin:
.idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

.DS_Store
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: android
android:
components:
- platform-tools
- extra
- android-23
- build-tools-23.0.1

before_install:
- chmod +x gradlew

script:
- ./gradlew clean build
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
OneDrive SDK Android

Copyright (c) 2015 Microsoft Corporation

All rights reserved.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
157 changes: 157 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# OneDrive Android SDK

[ ![Download](https://api.bintray.com/packages/onedrive/Maven/onedrive-sdk-android/images/download.svg) ](https://bintray.com/onedrive/Maven/onedrive-sdk-android/_latestVersion)
[![Build Status](https://travis-ci.org/OneDrive/onedrive-sdk-android.svg?branch=master)](https://travis-ci.org/OneDrive/onedrive-sdk-android)

Integrate the [OneDrive API](https://dev.onedrive.com/README.htm) into your Android application!

## 1. Installation
### 1.1 Install AAR via Gradle
Add the maven central repository to your projects build.gradle file then add a compile dependency for com.onedrive.sdk:onedrive-sdk-android:1.0.0

```gradle
repository {
jcenter()
}
dependency {
// Include the sdk as a dependency
compile('com.onedrive.sdk:onedrive-sdk-android:1.0.0')
// Include the gson dependency
compile 'com.google.code.gson:gson:2.3.1'
// Include supported authentication methods for your application
compile 'com.microsoft.services.msa:msa-auth:0.8.4'
compile 'com.microsoft.aad:adal:1.1.7'
}
```

## 2. Getting started

### 2.1 Register your application

Register your application by following [these](https://dev.onedrive.com/app-registration.htm) steps.

### 2.2 Set your application Id and scopes

The OneDrive SDK for Android comes with Authenticator objects that have already been initialized for OneDrive with Microsoft accounts and Azure Activity Directory accounts. Replace the current settings with the required settings to start authenticating.

Note that your _msa-client-id_ should look like `0000000000000000` and _adal-client-id_ should look like `00000000-0000-0000-0000-000000000000`.

```java
final MSAAuthenticator msaAuthenticator = new MSAAuthenticator {
@Override
public String getClientId() {
return "<msa-client-id>";
}

@Override
public String[] getScopes() {
return new String[] { "onedrive.appfolder" };
}
}

final ADALAuthenticator adalAuthenticator = new ADALAuthenticator {
@Override
public String getClientId() {
return "<adal-client-id>";
}

@Override
protected String getRedirectUrl() {
return "https://localhost";
}
}
```

### 2.3 Get a OneDriveClient object

Once you have set the correct application Id and scopes, you must get a **OneDriveClient** object to make requests against the service. The SDK will store the account information for you, but when a user logs on for the first time, it will invoke UI to get the user's account information.

```java
final IClientConfig oneDriveConfig = new DefaultClientConfig.createWithAuthenticators(
msaAuthenticator,
adalAuthenticator);

final IOneDriveClient oneDriveClient = new OneDriveClient
.Builder()
.fromConfig(oneDriveConfig)
.loginAndBuildClient(getActivity());

```

## 3. Make requests against the service

Once you have an OneDriveClient that is authenticated you can begin making calls against the service. The requests against the service look like our [REST API](https://dev.onedrive.com/README.htm).

### Get the drive

To retrieve a user's drive:

```java
oneDriveClient
.getDrive()
.buildRequest()
.get(new ICallback<Drive> {
@Override
public void success(final Drive result) {
final String msg = "Found Drive " + result.id;
Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT)
.show();
}
...
// Handle failure case
});
```

### Get the root folder

To get a user's root folder of their drive:

```java
oneDriveClient
.getDrive()
.getRoot()
.buildRequest()
.get(new ICallback<Item> {
@Override
public void success(final Item result) {
final String msg = "Found Root " + result.id;
Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT)
.show();
}
...
// Handle failure case
});
```

For a general overview of how the SDK is designed, see [overview](docs/overview.md).

## 4. Documentation

For a more detailed documentation see:

* [Overview](docs/overview.md)
* [Authentication](docs/authentication.md)
* [Extensibility](docs/extensibility.md)
* [Items](docs/items.md)
* [Collections](docs/collections.md)
* [Errors](docs/errors.md)
* [Contributions](docs/contributions.md)

## 5. Issues

For known issues, see [issues](https://github.com/OneDrive/onedrive-sdk-android/issues).

## 6. Contributions

The OneDrive SDK is open for contribution. Please read how to contribute to this project [here](docs/contributions.md).

## 7. License

[License](LICENSE)

## 8. Third Party Notices

[Third Party Notices](THIRD PARTY NOTICES)
26 changes: 26 additions & 0 deletions THIRD PARTY NOTICES
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
This file is based on or incorporates material from the projects listed below
(Third Party IP). The original copyright notice and the license under which
Microsoft received such Third Party IP, are set forth below. Such licenses and
notices are provided for informational purposes only. Microsoft licenses the
Third Party IP to you under the licensing terms for the Microsoft product.
Microsoft reserves all other rights not expressly granted under this agreement,
whether by implication, estoppel or otherwise.

Gson
Copyright 2008-2011 Google Inc.

Provided for Informational Purposes Only

Apache 2.0 License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0

THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.

See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
19 changes: 19 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}

allprojects {
repositories {
maven {
url project.nightliesUrl
}
jcenter()
}
}
Loading

0 comments on commit 26f0db8

Please sign in to comment.