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

Commit 26f0db8

Browse files
author
Peter Nied
committed
OneDrive SDK for Android
0 parents  commit 26f0db8

File tree

386 files changed

+27362
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

386 files changed

+27362
-0
lines changed

.gitignore

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Built application files
2+
*.apk
3+
*.ap_
4+
5+
# Files for the Dalvik VM
6+
*.dex
7+
8+
# Java class files
9+
*.class
10+
11+
# Generated files
12+
bin/
13+
gen/
14+
15+
# Gradle files
16+
.gradle/
17+
build/
18+
19+
# Local configuration file (sdk path, etc)
20+
local.properties
21+
22+
# Proguard folder generated by Eclipse
23+
proguard/
24+
25+
# Log Files
26+
*.log
27+
28+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
29+
*.iml
30+
.idea/
31+
32+
## Directory-based project format:
33+
34+
# User-specific stuff:
35+
.idea/workspace.xml
36+
.idea/tasks.xml
37+
.idea/dictionaries
38+
39+
# Sensitive or high-churn files:
40+
.idea/dataSources.ids
41+
.idea/dataSources.xml
42+
.idea/sqlDataSources.xml
43+
.idea/dynamic.xml
44+
.idea/uiDesigner.xml
45+
46+
# Gradle:
47+
.idea/gradle.xml
48+
.idea/libraries
49+
50+
# Mongo Explorer plugin:
51+
.idea/mongoSettings.xml
52+
53+
## File-based project format:
54+
*.ipr
55+
*.iws
56+
57+
.DS_Store

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: android
2+
android:
3+
components:
4+
- platform-tools
5+
- extra
6+
- android-23
7+
- build-tools-23.0.1
8+
9+
before_install:
10+
- chmod +x gradlew
11+
12+
script:
13+
- ./gradlew clean build

LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
OneDrive SDK Android
2+
3+
Copyright (c) 2015 Microsoft Corporation
4+
5+
All rights reserved.
6+
7+
MIT License
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in all
17+
copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
SOFTWARE.

README.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# OneDrive Android SDK
2+
3+
[ ![Download](https://api.bintray.com/packages/onedrive/Maven/onedrive-sdk-android/images/download.svg) ](https://bintray.com/onedrive/Maven/onedrive-sdk-android/_latestVersion)
4+
[![Build Status](https://travis-ci.org/OneDrive/onedrive-sdk-android.svg?branch=master)](https://travis-ci.org/OneDrive/onedrive-sdk-android)
5+
6+
Integrate the [OneDrive API](https://dev.onedrive.com/README.htm) into your Android application!
7+
8+
## 1. Installation
9+
### 1.1 Install AAR via Gradle
10+
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
11+
12+
```gradle
13+
repository {
14+
jcenter()
15+
}
16+
17+
dependency {
18+
// Include the sdk as a dependency
19+
compile('com.onedrive.sdk:onedrive-sdk-android:1.0.0')
20+
21+
// Include the gson dependency
22+
compile 'com.google.code.gson:gson:2.3.1'
23+
24+
// Include supported authentication methods for your application
25+
compile 'com.microsoft.services.msa:msa-auth:0.8.4'
26+
compile 'com.microsoft.aad:adal:1.1.7'
27+
}
28+
```
29+
30+
## 2. Getting started
31+
32+
### 2.1 Register your application
33+
34+
Register your application by following [these](https://dev.onedrive.com/app-registration.htm) steps.
35+
36+
### 2.2 Set your application Id and scopes
37+
38+
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.
39+
40+
Note that your _msa-client-id_ should look like `0000000000000000` and _adal-client-id_ should look like `00000000-0000-0000-0000-000000000000`.
41+
42+
```java
43+
final MSAAuthenticator msaAuthenticator = new MSAAuthenticator {
44+
@Override
45+
public String getClientId() {
46+
return "<msa-client-id>";
47+
}
48+
49+
@Override
50+
public String[] getScopes() {
51+
return new String[] { "onedrive.appfolder" };
52+
}
53+
}
54+
55+
final ADALAuthenticator adalAuthenticator = new ADALAuthenticator {
56+
@Override
57+
public String getClientId() {
58+
return "<adal-client-id>";
59+
}
60+
61+
@Override
62+
protected String getRedirectUrl() {
63+
return "https://localhost";
64+
}
65+
}
66+
```
67+
68+
### 2.3 Get a OneDriveClient object
69+
70+
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.
71+
72+
```java
73+
final IClientConfig oneDriveConfig = new DefaultClientConfig.createWithAuthenticators(
74+
msaAuthenticator,
75+
adalAuthenticator);
76+
77+
final IOneDriveClient oneDriveClient = new OneDriveClient
78+
.Builder()
79+
.fromConfig(oneDriveConfig)
80+
.loginAndBuildClient(getActivity());
81+
82+
```
83+
84+
## 3. Make requests against the service
85+
86+
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).
87+
88+
### Get the drive
89+
90+
To retrieve a user's drive:
91+
92+
```java
93+
oneDriveClient
94+
.getDrive()
95+
.buildRequest()
96+
.get(new ICallback<Drive> {
97+
@Override
98+
public void success(final Drive result) {
99+
final String msg = "Found Drive " + result.id;
100+
Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT)
101+
.show();
102+
}
103+
...
104+
// Handle failure case
105+
});
106+
```
107+
108+
### Get the root folder
109+
110+
To get a user's root folder of their drive:
111+
112+
```java
113+
oneDriveClient
114+
.getDrive()
115+
.getRoot()
116+
.buildRequest()
117+
.get(new ICallback<Item> {
118+
@Override
119+
public void success(final Item result) {
120+
final String msg = "Found Root " + result.id;
121+
Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT)
122+
.show();
123+
}
124+
...
125+
// Handle failure case
126+
});
127+
```
128+
129+
For a general overview of how the SDK is designed, see [overview](docs/overview.md).
130+
131+
## 4. Documentation
132+
133+
For a more detailed documentation see:
134+
135+
* [Overview](docs/overview.md)
136+
* [Authentication](docs/authentication.md)
137+
* [Extensibility](docs/extensibility.md)
138+
* [Items](docs/items.md)
139+
* [Collections](docs/collections.md)
140+
* [Errors](docs/errors.md)
141+
* [Contributions](docs/contributions.md)
142+
143+
## 5. Issues
144+
145+
For known issues, see [issues](https://github.com/OneDrive/onedrive-sdk-android/issues).
146+
147+
## 6. Contributions
148+
149+
The OneDrive SDK is open for contribution. Please read how to contribute to this project [here](docs/contributions.md).
150+
151+
## 7. License
152+
153+
[License](LICENSE)
154+
155+
## 8. Third Party Notices
156+
157+
[Third Party Notices](THIRD PARTY NOTICES)

THIRD PARTY NOTICES

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
This file is based on or incorporates material from the projects listed below
2+
(Third Party IP). The original copyright notice and the license under which
3+
Microsoft received such Third Party IP, are set forth below. Such licenses and
4+
notices are provided for informational purposes only. Microsoft licenses the
5+
Third Party IP to you under the licensing terms for the Microsoft product.
6+
Microsoft reserves all other rights not expressly granted under this agreement,
7+
whether by implication, estoppel or otherwise.
8+
9+
Gson
10+
Copyright 2008-2011 Google Inc.
11+
12+
Provided for Informational Purposes Only
13+
14+
Apache 2.0 License
15+
16+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
17+
this file except in compliance with the License. You may obtain a copy of the
18+
License at http://www.apache.org/licenses/LICENSE-2.0
19+
20+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
21+
ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
22+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
23+
MERCHANTABLITY OR NON-INFRINGEMENT.
24+
25+
See the Apache Version 2.0 License for specific language governing permissions
26+
and limitations under the License.

build.gradle

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
3+
buildscript {
4+
repositories {
5+
jcenter()
6+
}
7+
dependencies {
8+
classpath 'com.android.tools.build:gradle:1.3.0'
9+
}
10+
}
11+
12+
allprojects {
13+
repositories {
14+
maven {
15+
url project.nightliesUrl
16+
}
17+
jcenter()
18+
}
19+
}

0 commit comments

Comments
 (0)