Step 6: Implementing the applicationΒΆ

Implementing a Dataporten appliation is as easy as creating any OAuth 2.0 client.

In this demo we created a web application using javascript.

The OAuth details is hidden in the JSO library that we used. And the actual code needed in order to authenticate the use, obtain information about the enduser as well as getting data from Foodle API on behalf of the authenticated user, is something like this:


feideconnect.authenticate.then(function(user) { 
    console.log("The authenticated user is ", user);
}); 

var scopes = \["userinfo", "gk\_foodle"\]; 
feideconnect.\_customRequest('https://foodle.gk.feideconnect.no/api2/foodlelist', scopes, scopes).then(function(result) { 
    console.log("A list of foodle data", result); 
});