Skip to content
This repository was archived by the owner on Apr 6, 2025. It is now read-only.

Step 1: Create connection

Ole Melhus edited this page Oct 11, 2017 · 6 revisions

Create a new token using the OAuth flow

var dev_client_id = "...";
var dev_secret = "...";
var redirect_url = "http://localhost:44300/VismaNet/callback";
var url = VismaNet.GetOAuthUrl(dev_client_id, redirect_url);
Console.WriteLine($"Open this URL in your browser: {url}");

Console.Write("Paste code from URL: ");
var code = Console.ReadLine();
var token = await VismaNet.GetTokenUsingOAuth(dev_client_id, dev_secret, code, redirect_url);
var contexts = await VismaNet.GetContextsForToken(token);
foreach (var ctx in contexts)
{
    Console.WriteLine($"{ctx.name}: {ctx.id}");
}

Create a new token and list available companies

var client_id = "client_id_from_visma";
var client_secret = "client_secret_from_visma";
var token = await VismaNet.GetToken("test@visma.com", "superMegaSecretPassword!", client_id, client_secret);
var contexts = await VismaNet.GetContextsForToken(token);
foreach (var ctx in contexts)
{
    Console.WriteLine($"{ctx.name}: {ctx.id}");
}

Create a new connection with a known token and context

var companyId = 100000;
var token = "2d576ad3-5fbe-b7e6-1ce2-0fb41c530187";
var vismaNet = new VismaNet(companyId, token);

Clone this wiki locally