From 403c32debfe7916ee560b72da177ab0b8df7cb84 Mon Sep 17 00:00:00 2001 From: Nakul Sabharwal Date: Fri, 8 Mar 2019 13:12:09 +0530 Subject: [PATCH 1/2] Edited readme --- readme.md | 66 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/readme.md b/readme.md index 22e38fc0a..6394ae630 100644 --- a/readme.md +++ b/readme.md @@ -1,15 +1,12 @@ # Microsoft Graph Core SDK for Java -[ ![Download](https://api.bintray.com/packages/microsoftgraph/Maven/microsoft-graph/images/download.svg) ](https://bintray.com/microsoftgraph/Maven/microsoft-graph/_latestVersion) - - Get started with the Microsoft Graph Core SDK for Java by integrating the [Microsoft Graph API](https://graph.microsoft.io/en-us/getting-started) into your Java application! ## 1. Installation ### 1.1 Install via Gradle -Add the repository and a compile dependency for `microsoft-graph` to your project's `build.gradle`: +Add the repository and a compile dependency for `microsoft-graph-core` to your project's `build.gradle`: ```gradle repository { @@ -70,33 +67,59 @@ Register your application by following the steps at [Register your app with the ### 2.2 Create an IAuthenticationProvider object -An instance of the **GraphServiceClient** class handles building requests, sending them to the Microsoft Graph API, and processing the responses. To create a new instance of this class, you need to provide an instance of `IAuthenticationProvider`, which can authenticate requests to Microsoft Graph. - -For an example of authentication in a client application, see the [MSGraph SDK Android MSA Auth for Android Adapter](https://github.com/microsoftgraph/msgraph-sdk-android-msa-auth-for-android-adapter). +An instance of the **HttpClients** class handles building client. To create a new instance of this class, you need to provide an instance of `ICoreAuthenticationProvider`, which can authenticate requests to Microsoft Graph. -### 2.3 Get a HttpClient object -You must get a **HttpClient** object to make requests against the service. +### 2.3 Get a HttpClients object +You must get a **HttpClients** object to make requests against the service. ```java -CloseableHttpClient httpClient = HttpClients.createDefault(authenticationProvider); +OkHttpClient client = HttpClients.createDefault(iCoreAuthenticationProvider); ``` ## 3. Make requests against the service -After you have a HttpClient that is authenticated, you can begin making calls against the service. The requests against the service look like our [REST API](https://developer.microsoft.com/en-us/graph/docs/concepts/overview). +After you have a HttpClients that is authenticated, you can begin making calls against the service. The requests against the service look like our [REST API](https://developer.microsoft.com/en-us/graph/docs/concepts/overview). -### 3.1 Get the user's drive +### 3.1 Get the user's details + +To retrieve the user's details + +```java +Request request = new Request.Builder().url("https://graph.microsoft.com/v1.0/me/").build(); + +client.newCall(request).enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) throws IOException { + String responseBody = response.body().string(); + // Your processing with the response body + } + + @Override + public void onFailure(Call call, IOException e) { + e.printStackTrace(); + } +}); +``` + +### 3.2 Get the user's drive To retrieve the user's drive: ```java -HttpGet httpget = new HttpGet("https://graph.microsoft.com/v1.0/me/"); -try{ - HttpResponse response = httpclient.execute(httpget); - //... -}catch(IOException e){ -//Handle exception -} +Request request = new Request.Builder().url("https://graph.microsoft.com/v1.0/me/drive").build(); + +client.newCall(request).enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) throws IOException { + String responseBody = response.body().string(); + // Your processing with the response body + } + + @Override + public void onFailure(Call call, IOException e) { + e.printStackTrace(); + } +}); ``` ## 4. Issues @@ -105,11 +128,12 @@ For known issues, see [issues](https://github.com/MicrosoftGraph/msgraph-sdk-jav ## 5. Contributions -The Microsoft Graph SDK is open for contribution. To contribute to this project, see [Contributing](https://github.com/microsoftgraph/msgraph-sdk-java/blob/master/CONTRIBUTING.md). +The Microsoft Graph SDK is open for contribution. To contribute to this project, see [Contributing](https://github.com/microsoftgraph/msgraph-sdk-java-core/blob/master/CONTRIBUTING.md). -[
Deepak Agrawal](https://github.com/deepak2016)
[💻](https://github.com/microsoftgraph/msgraph-sdk-java/commits?author=deepak2016 "Code") +| [
Deepak Agrawal](https://github.com/deepak2016)
[??](https://github.com/microsoftgraph/msgraph-sdk-java-core/commits?author=deepak2016 "Code") | [
Nakul Sabharwal][??](https://github.com/microsoftgraph/msgraph-sdk-java-core/commits?author=NakulSabharwal "Code") (https://developer.microsoft.com/graph)
[](#question-NakulSabharwal "Answering Questions") [](https://github.com/microsoftgraph/msgraph-sdk-android-auth/commits?author=NakulSabharwal "Code") [](https://github.com/microsoftgraph/msgraph-sdk-android-auth/wiki "Documentation") [](#review-NakulSabharwal "Reviewed Pull Requests") [](https://github.com/microsoftgraph/msgraph-sdk-android-auth/commits?author=NakulSabharwal "Tests")
+| :---: | :---: | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind are welcome! From 32ef267be4c4beaed6812726a96ef2f6cbe2d004 Mon Sep 17 00:00:00 2001 From: NakulSabharwal Date: Fri, 8 Mar 2019 13:16:36 +0530 Subject: [PATCH 2/2] edited contributor list --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 6394ae630..65c6528c4 100644 --- a/readme.md +++ b/readme.md @@ -132,7 +132,7 @@ The Microsoft Graph SDK is open for contribution. To contribute to this project, -| [
Deepak Agrawal](https://github.com/deepak2016)
[??](https://github.com/microsoftgraph/msgraph-sdk-java-core/commits?author=deepak2016 "Code") | [
Nakul Sabharwal][??](https://github.com/microsoftgraph/msgraph-sdk-java-core/commits?author=NakulSabharwal "Code") (https://developer.microsoft.com/graph)
[](#question-NakulSabharwal "Answering Questions") [](https://github.com/microsoftgraph/msgraph-sdk-android-auth/commits?author=NakulSabharwal "Code") [](https://github.com/microsoftgraph/msgraph-sdk-android-auth/wiki "Documentation") [](#review-NakulSabharwal "Reviewed Pull Requests") [](https://github.com/microsoftgraph/msgraph-sdk-android-auth/commits?author=NakulSabharwal "Tests")
+| [
Deepak Agrawal](https://github.com/deepak2016)
[:computer:](https://github.com/microsoftgraph/msgraph-sdk-java-core/commits?author=deepak2016 "Code") | [
Nakul Sabharwal][:computer:](https://github.com/microsoftgraph/msgraph-sdk-java-core/commits?author=NakulSabharwal "Code")
[](#question-NakulSabharwal "Answering Questions") [](https://github.com/microsoftgraph/msgraph-sdk-android-auth/commits?author=NakulSabharwal "Code") [](https://github.com/microsoftgraph/msgraph-sdk-android-auth/wiki "Documentation") [:clipboard:](#review-NakulSabharwal "Reviewed Pull Requests") [](https://github.com/microsoftgraph/msgraph-sdk-android-auth/commits?author=NakulSabharwal "Tests")
| :---: | :---: |