Configuring KanBo app

If you want to use KanBo API via KanBo.Client.dll you have to first configure your KanBo app. Inside web.config file in section  you have to register X509 certificate that will be used for authentication (you can even generate it by yourself using makecert, see CreateCert.ps1 in Api Sample) .

Download KanBo API methods here.

Provider types for certificates

As shown above, there are different provider types for certificates:

AppSingedLogin” – when using this provider type your service will be seen as user which login you provide and will have exactly same permissions as that user.

On-prem login will look like this:
`i:0#.w|domain\user` `domain\user`

O365 login will look like this:
`i:0#.f|membership|[email protected]` `[email protected]`

XML:
{signer}

AppSignedUser” – when using this provider type your service will be seen as user defined by you in code and will have exactly same permissions as that user.

XML:
{signer}

AppSignedService” – when using this provider type your service will be seen as Service and will have permissions defined by KanBo – full access to everything on KanBo.

XML:
`{signer}

Signer

The `signer` declares which certificate will be used to validate the signature of given token, possible types are:

– **X509SignerFromFile** – contains a public or private key read from a file by specified path (you can use either .cer or .pfx here, pfx file will need a key).
XML:

**X509SignerFromStore** – contains a public or private key read from a certificate in given certificate store by specified property.
XML:

Parameters required for KanBo API object creation:

  1. kanboUrl – base url of KanBo web (example: “//kanboapp.developer.local”)
  2. instanceId – id of an KanBo instance (only for KanBo versions lower than 2.7)
  3. userId – id of a user our service will impersonate (only for userToken). Example: 1
  4. loginName= login of kanbo user  – required for login type security token. Example: “i:0#.w|developer\\administrator”
  5. certificatePath – path for the certificate that was registered in KanBo web.config
  6. certificatePassword – password to certificate mentioned above
  7. duration- it will define for how long the token is valid (after that it’s re-issued) – it’s suggested to use the default value, however if your clocks are synchronized, if not, you may consider using [special tokens that synchronize your client with server](//bitbucket.org/objectconnect/kanbo-additionaltokens)
  8. UserToken – if we want our app to work as signed user (AppSignedUser provider)
  9. ServiceToken – if we want our app to work as signed service (AppSignedService provider)
  10. LoginToken – if we want our app to work as signed user (AppSignedLogin provider)
  11. MobileToken

Creating API object

To create our KanBo API object first we need to create a security token. There are several types of tokens.

Types of tokens

Here are examples of how to create all token types:

1. Generating token for user scope
var loginToken = new LoginToken(KanBoIssuers.Login, loginName, TimeSpan.FromMinutes(10), userCer);
2. Generating token for user scope
var userToken = new UserToken(KanBoIssuers.User, userId, TimeSpan.FromMinutes(10), userCer);
3. Generating token for service scope
var serviceToken = new ServiceToken(KanBoIssuers.Service, TimeSpan.FromMinutes(10), userCer);
4. Generating mobile token
var mobileToken = new MobileTokenSource("administrator", "adminpassword", "//kanboapp.developer.local");

API Requester object

Next, there is a need to create a requester object for our API.

Example:
var jsonRequester = new JsonApiRequester(mobileToken, kanboUrl, httpClient);

Create API Object using a chosen requester

The last step is to create API object with use of a chosen requester:

1. Creating API object
var api = new Api(jsonRequester);
2. Creating uploader object for file upload
var uploader = new Uploader(kanboUrl, jsonRequester);

Calling methods

All methods in our API can be called in the following manner:

1. Get Groups in a Board
var groups = await api.GetData(KanBoGetDataMethods.GroupsInBoard, new { BoardId = 2 });
2. Get information about this KanBo API methods arguments
var info = await api.GetMethodInfo(KanBoGetDataMethods.Board);
3. Get current user
var usr = await api.GetData(KanBoGetDataMethods.CurrentUser, new { });
4. Getting a board
var board = await api.GetData(KanBoGetDataMethods.Board, new { Id = 2 });
5. Uploading a file to Board and attaching it to card
await Upload(145, uploader, api);

Available methods

There are 2 types of KanBo API methods:
– GetData methods
– Actions methods

You can download a document containing a whole list of KanBo API methods by clicking here.

Get started with KanBo today and accelerate your business like never before