diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..ce9857de51beaea848ff1658fd925aeddb2811c0 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +# Genesys Client API changelog + +## Release 1.2 + +October 2017 + + - 4aeb301 Logging + - 4c12425 Upgraded to scribe-java:4.2.0 diff --git a/README.md b/README.md index 676b168438a2d629b00f1eaa9c317999e0d1ad83..1bf6ba2e08612dc5f17340afafeabdd56549e6c9 100644 --- a/README.md +++ b/README.md @@ -2,22 +2,25 @@ **genesys-client-api** library aims to ease integration of your existing accession management software in Java with [Genesys PGR portal](https://www.genesys-pgr.org "Visit Genesys PGR"). -## Using the API client - -### Initializing the client +## Initializing the client ```java -GenesysClient genesysClient = new GenesysClient(); -// Set the Scribe OAuth API implementation -genesysClient.setGenesysApi(new GenesysApi()); // Set server URL -genesysClient.setBaseUrl("https://www.genesys-pgr.org"); -// Specify clientKey, secret and the callback URL as registered on the server -genesysClient.connect(clientKey, clientSecret, callbackUrl); +String baseUrl = "https://www.genesys-pgr.org"; +String clientId = "theClientId@genesys"; +String clientSecret = "thesecret"; +String callbackUrl = "oob"; +String scope = "write"; // write scope is required to manage data on Genesys +GenesysClient genesysClient = new GenesysClient(baseUrl, clientId, clientSecret, callbackUrl, scope); +``` -// Ask end user to navigate to Genesys server and authorize your access to their resources -String authorizationUrl = genesysClient.getAuthorizationUrl(GenesysClient.EMPTY_TOKEN); -// Open this URL in browser, login and allow us to access your resources and come back with the code +### Authentication + +```java +// Authenticate the user +String authorizationUrl = genesysClient.getAuthorizationUrl(); +// The user must now open the authorizationUrl in the browser and approve the +// request on Genesys website. User gets the verifierCode. String verifierCode = null; // whatever user provides genesysClient.authenticate(verifierCode); @@ -25,8 +28,24 @@ genesysClient.authenticate(verifierCode); genesysClient.me(); // Tokens are now accessible. The refreshToken must be **safely** stored for future use. +// genesysClient.getTokens().getAccessToken(); +// genesysClient.getTokens().getRefreshToken(); +``` + +### Re-using tokens + +If you have existing tokens you can provide the access and refresh tokens when +initializing the client: + +```java +GenesysTokens genesysTokens = new GenesysTokens(); +genesysTokens.setAccessToken("someaccesstoken"); +genesysTokens.setRefreshToken("somerefreshtoken"); +genesysClient.setTokens(genesysTokens); ``` +## Using the API client + Updating data: ```java @@ -54,7 +73,7 @@ try { org.genesys-pgr genesys-client-api - 1.1 + 1.2 ``` @@ -64,7 +83,7 @@ Or for the development version: org.genesys-pgr genesys-client-api - 1.2-SNAPSHOT + 1.3-SNAPSHOT ``` @@ -77,6 +96,6 @@ Or for the development version: ### Your new project - Create a new Maven project in Eclipse, if starting from scratch -- Add dependency on `org.genesys-pgr:genesys-client-api` artefact to your `pom.xml` +- Add dependency on `org.genesys-pgr:genesys-client-api` artifact to your `pom.xml` - Create your integration project - Contact helpdesk@genesys-pgr.org for assistance if required diff --git a/pom.xml b/pom.xml index 46efeb18846040fcc08f461d076db419a85e1a02..b2cda4a4df12458ca22aaed714d46842b26b92a2 100644 --- a/pom.xml +++ b/pom.xml @@ -1,10 +1,9 @@ - + 4.0.0 org.genesys-pgr genesys-client-api - 1.2-SNAPSHOT + 1.3-SNAPSHOT Genesys API client library jar https://bitbucket.org/genesys2/genesys-client-api