Podio Java Client
The Java client provides coverage of a large part of the API.
Getting the client
The client is built using Maven and is available in the official Maven repository. To use the client in a Maven project simply add a dependency on
com.podio.api. If you use Eclipse, you can follow these steps:
- Create a new Maven project (make sure you have Maven integration installed)
pom.xmland go to the
- Click the
Addbutton in the Dependencies list to the left
"podio"in the search field and select the newest version of
OKand rebuild the project
The client can also be used by cloning the GitHub repository at https://github.com/podio/podio-java using the command
git clone firstname.lastname@example.org:podio/podio-java.git.
Constructing API client instance and authentication
The main entry point for the API client is the
com.podio.APIFactory class. This class supplies methods for getting API interfaces for each of the API areas. To construct a new API factory a
com.podio.ResourceFactory instance must be supplied. The resource factory takes two parameters for construction, the client credentials and the authentication credentials. The client credentials are the key and secret from the API client registration. The authentication credentials can be any of the different authentication methods described in the authentication article.
ResourceFactory resourceFactory = new ResourceFactory( new OAuthClientCredentials(clientId, clientSecret), new OAuthUsernameCredentials(username, password)); APIFactory apiFactory = new APIFactory(resourceFactory);
The API factory can then be used to get an interface for each of the areas of the API. The following will get the user area and then use the area to get the profile for the authenticated user and print out the name.
UserAPI userAPI = apiFactory.getAPI(UserAPI.class); Profile profile = userAPI.getProfile(); System.out.println(profile.getName());
There are many samples available on how the Java client can be used. They are all available on GitHub: