App authentication

This page provides detailed instructions on how to authenticate your app to make InfoJobs API calls.

Every API request has to be authenticated to help us keep track of the developer and app making a request. App authentication is done via HTTP basic access authentication.

If you tried a request without authentication like this:

GET /api/1/offer HTTP/1.1

The server response would be something like:

HTTP/1.1 401 No Autorizado
WWW-Authenticate: Basic realm="InfoJobs-API"
Connection: close
Content-Type: application/json

For our operations to work you have to provide an HTTP header named Authorization with the provided Client ID and a Client secret separated by a colon and base64 encoded. For example, if your Client ID is Aladdin and your Client secret is open sesame the above request would be:

GET /api/1/offer HTTP/1.1
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==

And now the call would succeed.

If you want to try the authentication we provide you with this simple form that will give you the authentication header given your Client ID and Client secret. The text under the form will change automatically once you start typing.

Client credentials
	Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==

Most of the common programming languages provide simple ways to perform HTTP basic access authentication. For example if you use Java and an Apache HTTPClient from Apache HttpComponents library you could write a simple InfoJobs API client that gets a list of job offers currently available on our site with the code below.

import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
* A simple example of HTTP basic access authentication. 
* @author A cool InfoJobs dev ;)
public class BasicAuthenticationExample {
public static void main(String[] args) throws Exception {
DefaultHttpClient client = new DefaultHttpClient();	
HttpHost targetHost = new HttpHost("", 443, "https"); 
// Provide the credentials to be used for the host against which 
// authentication is to be attempted.
new AuthScope(targetHost.getHostName(), targetHost.getPort()), 		
new UsernamePasswordCredentials("Aladdin", "open sesame")
// create a GET method that queries some API operation
HttpGet request = new HttpGet("/api/1/offer");	
try {
// execute the operation
HttpResponse response = client.execute(targetHost, request);
// print the status and the contents of the response
} finally {
// release any connection resources used by the method

That's it!

We have coded our first InfoJobs API client with about 5 lines of code.