Skip to content

Commit 1b204fa

Browse files
committed
Update README.md
1 parent 03f9777 commit 1b204fa

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

README.md

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@
55
* [Documentation](#documentation)
66
* [Getting Started](#getting-started)
77
* [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)
1016

1117
## Current release of SDK with oAuth 2 support
1218
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 {
439445
}
440446
```
441447

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-
458448
## Example Calls
459449

460450
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 {
584574
}
585575
```
586576

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+
587593
## Client Credential Grant Type
588594

589595
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.
590596

591597
```java
592-
final String clientId = "--CLIENT-ID--";
598+
final String clientId = "--CLIENT-ID--";
593599
final String clientSecret = "--CLIENT-SECRET--";
594-
final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport();
600+
final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport();
595601
final JsonFactory JSON_FACTORY = new JacksonFactory();
596602

597-
ArrayList<String> appStoreScopeList = new ArrayList<String>();
603+
ArrayList<String> appStoreScopeList = new ArrayList<String>();
598604
appStoreScopeList.add("marketplace.billing");
599605

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();
606612
```
607613

608614
## Working with dates

0 commit comments

Comments
 (0)