|
5 | 5 | * [Documentation](#documentation) |
6 | 6 | * [Getting Started](#getting-started) |
7 | 7 | * [How to use the SDK](#how-to-use-the-xero-java-sdk) |
8 | | - |
9 | | - |
| 8 | +* [Example Calls](#example-calls) |
| 9 | +* [Revoking a token](#revoking-token) |
| 10 | +* [Client credential grant type](##client-credential-grant-type) |
| 11 | +* [Working with dates](#working-with-dates) |
| 12 | +* [Exception Handling](#exception-handling) |
| 13 | +* [Logging](#logging) |
| 14 | +* [Older versions](#older-versions) |
| 15 | +* [Contributing](#participating-in-xeros-developer-community) |
10 | 16 |
|
11 | 17 | ## Current release of SDK with oAuth 2 support |
12 | 18 | Version 4.x and higher of Xero Java SDK only supports OAuth2 authentication and the following API sets. |
@@ -439,22 +445,6 @@ public class TokenRefresh { |
439 | 445 | } |
440 | 446 | ``` |
441 | 447 |
|
442 | | -## Revoking Token |
443 | | - |
444 | | -You can revoke a user's refresh token and remove all their connections to your app by making a request to the revocation endpoint. |
445 | | - |
446 | | -We've added a helpful method to the ApiClient class. The code below shows how to pass the id, secret and refresh token to execute the revoke method. Success |
447 | | - |
448 | | -```java |
449 | | -try { |
450 | | - ApiClient apiClient = new ApiClient(); |
451 | | - HttpResponse revokeResponse = apiClient.revoke(clientId, clientSecret, refreshToken); |
452 | | - System.out.println("Revoke success: " + revokeResponse.getStatusCode()); |
453 | | -} catch (Exception e) { |
454 | | - System.out.println(e.getMessage()); |
455 | | -} |
456 | | -``` |
457 | | - |
458 | 448 | ## Example Calls |
459 | 449 |
|
460 | 450 | The Xero Java SDK contains Client classes (AccountingApi, etc) which have helper methods to perform (Create, Read, Update and Delete) actions on each endpoints. AccountingApi is designed as a Singleton. Use the getInstance method of the class class and use with API models to interact with Java Objects. |
@@ -584,25 +574,41 @@ public class AuthenticatedResource extends HttpServlet { |
584 | 574 | } |
585 | 575 | ``` |
586 | 576 |
|
| 577 | +## Revoking Token |
| 578 | + |
| 579 | +You can revoke a user's refresh token and remove all their connections to your app by making a request to the revocation endpoint. |
| 580 | + |
| 581 | +We've added a helpful method to the ApiClient class. The code below shows how to pass the id, secret and refresh token to execute the revoke method. Success |
| 582 | + |
| 583 | +```java |
| 584 | +try { |
| 585 | + ApiClient apiClient = new ApiClient(); |
| 586 | + HttpResponse revokeResponse = apiClient.revoke(clientId, clientSecret, refreshToken); |
| 587 | + System.out.println("Revoke success: " + revokeResponse.getStatusCode()); |
| 588 | +} catch (Exception e) { |
| 589 | + System.out.println(e.getMessage()); |
| 590 | +} |
| 591 | +``` |
| 592 | + |
587 | 593 | ## Client Credential Grant Type |
588 | 594 |
|
589 | 595 | The code below shows how to perform the OAuth 2 client credential grant flow. [Custom connections](https://developer.xero.com/announcements/custom-integrations-are-coming/) will utilize this flow when it becomes available. |
590 | 596 |
|
591 | 597 | ```java |
592 | | - final String clientId = "--CLIENT-ID--"; |
| 598 | + final String clientId = "--CLIENT-ID--"; |
593 | 599 | final String clientSecret = "--CLIENT-SECRET--"; |
594 | | - final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport(); |
| 600 | + final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport(); |
595 | 601 | final JsonFactory JSON_FACTORY = new JacksonFactory(); |
596 | 602 |
|
597 | | - ArrayList<String> appStoreScopeList = new ArrayList<String>(); |
| 603 | + ArrayList<String> appStoreScopeList = new ArrayList<String>(); |
598 | 604 | appStoreScopeList.add("marketplace.billing"); |
599 | 605 |
|
600 | | - // client_credentials |
601 | | - TokenResponse tokenResponse = new ClientCredentialsTokenRequest(HTTP_TRANSPORT, JSON_FACTORY, |
602 | | - new GenericUrl("https://identity.xero.com/connect/token")) |
603 | | - .setScopes(appStoreScopeList) |
604 | | - .setClientAuthentication( new BasicAuthentication(clientId, clientSecret)) |
605 | | - .execute(); |
| 606 | + // client_credentials |
| 607 | + TokenResponse tokenResponse = new ClientCredentialsTokenRequest(HTTP_TRANSPORT, JSON_FACTORY, |
| 608 | + new GenericUrl("https://identity.xero.com/connect/token")) |
| 609 | + .setScopes(appStoreScopeList) |
| 610 | + .setClientAuthentication( new BasicAuthentication(clientId, clientSecret)) |
| 611 | + .execute(); |
606 | 612 | ``` |
607 | 613 |
|
608 | 614 | ## Working with dates |
|
0 commit comments