When using the Net SDK the credentials are encrypted and stored locally in a configuration file - SwPTrmLib.dll.config. The encryption is only valid on the specific machine so the file cannot be copied to another machine. The file is created and maintained through the interface IConfigInit which contains two methods for setting client id and the secret. To retrieve the interface use the static methods ConfigInit.Create4Test() or ConfigInit.Create4Prod().
The simple interface for creating a config file with credentials.
1
2
3
4
5
6
7
8
namespace SwpTrmLib.Cloud
{
public interface IConfigInit
{
void SetClientId(string id);
void SetClientSecret(string secret);
}
}
There will be one config file per POIID, so the SwPTrmLib.dll.config is just used as a template for the poiid config file which name is <POIID>.dll.config. The POIID configuration file is created when calling ISwpTrmIf_1.Start. If the template file doesn’t exist it is created but then without credentials. You may copy the credentials in clear into the template file and then remove the created POIID config file and call ISwpTrmIf_1.Start again. The credentials are then encrypted and a new configuration file for the POIID is created. This approach is not the easy way. The preferred way is to create the file with credentials before calling ISwpTrmIf_1.Start.
The credentials are valid for 24 months so make sure they are easily maintained. The Client id and secret is valid per partner or integrator in most cases.
Example of contetent of a config file. This is after pairing has been done.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings file="">
<clear />
<add key="Secret" value="AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAI24frRP+ake+Phr6N48kagAAAAACAAAAAAAQZgAAAAEAACAAAAARMa8uFnu+o/BF5lQ2hkxiqZWrzYW/m5t+0jer6MIvHAAAAAAOgAAAAAIAACAAAACKPAae2vD72iTFTHGTvHazVNsDJ56xfSoSfP35tqHYxDAAAAD6mjteYVnzayZEgZgoTgaBlXr1ApkrayqiuESBvN4tqta3RNSCysU/lO1X+RqQJh1AAAAAuozjgk8hQ0W2PlBnzeH9dNYCvTVgx/t+GUHMPCrAx9TbxLiiR6IIA4EFNl2i3oEaSRf4fdGK+XEmRsBi+jGlSA==" />
<add key="ClientId" value="AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAI24frRP+ake+Phr6N48kagAAAAACAAAAAAAQZgAAAAEAACAAAABeHQmVwuFg3fUKhFPZHbjNt8olaZRHzEGSHGPcG625UAAAAAAOgAAAAAIAACAAAAAjKPUYPs73dq9rfkl6kzbKtGelg7kUw9L0Uzgqiw3NGTAAAACWObx14RnCzb313OG9cAPjiorUv5KOwQ1R5lZl3jdTA+ERPxW06mbVR7CJPTwn6y9AAAAAbkzaJEh/BmcOV/doaE0ngpm7+iLMrrHJEoc1m0ZRGRbQy+D2E4uL5+UhMROidCkGxxWSX0ZIUiWyaP0xbjF4NQ==" />
<add key="Scope" value="https://swppciextdev.onmicrosoft.com/terminal-api/.default" />
<add key="GetTokenUrl" value="https://swppciextdev.b2clogin.com/swppciextdev.onmicrosoft.com/B2C_1_terminal/oauth2/v2.0/token" />
<add key="BaseURL" value="https://cloudconnect.stage.swedbankpay.com" />
<add key="PairingUri" value="/api/v1/pairing" />
<add key="NexoUri" value="/api/v1/channels/#channelid#/nexo" />
<add key="EventsUri" value="/api/v1/channels/#channelid#/events" />
<add key="AccessToken" value="AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAI24frRP+ake+Phr6N48kagAAAAACAAAAAAAQZgAAAAEAACAAAADYP+Droh65YD6QOzGPToTwKVDgMeQ1YU0yldqiw/sMlwAAAAAOgAAAAAIAACAAAAB7Kejh8VmSVFv3QElHX+91ckfliOWAc2x6iwR7FHkDDxAEAABiWPFFd9n0H5uBS7Swhrxu58Fj8HHrzSXM51Ff8kOAd6gDCwvaJ+tysoMUVsFa3b0NIT2UvECFnx70sok+jq68jq/tsoA1vlkrSWRwmK3gcN1E10C3S8ABiG2A4TdHKf3XwHy6ZxxwOVRZwVyWMXUGP2rwMPRua+VxtZspexmQNJb2gUsvNSHLO0TCGwrkHXcUSlLWS3KXLjYmC+Vr4fTWml6ObEZTUlaDO8qdWjVjTyveUZbrxIS3KgkE9sv2dal/e+V4VYcXRlDe5NS4ardiMUVj0sOQIp7gzvrd+KrQHn3Zjz9x+w7sincbofXyEod33Co8dpvfUgCxY+MQskyfRTZIgzai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bWZWSb174RVjWJKgh3BpIFhvrfRYV3rDuA8cjICH5+/pDqF" />
<add key="ExpiresOn" value="2025-12-17 16:40:22" />
<add key="RenewAt" value="2025-12-17 16:30:22" />
<add key="ChannelID" value="AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAI24frRP+ake+Phr6N48kagAAAAACAAAAAAAQZgAAAAEAACAAAACZniBBkZ++sh/moOLZuUgRTOpAirCOoyYLc67fBuse5wAAAAAOgAAAAAIAACAAAABI1Ve11tm8JMgl0nv3HV7ylXETsN7o7zkaFMXGIXxnLTAAAACLjO9PdkRS0qW76VMF0cSL6bRRKclsnLfSnrQvdvcZP5b5U7TW44BAAQ6ennDDgDpAAAAAstcvWUu6Md9uDycRi8z4GAr5K0V2EG0xaelNfBP1hAxe/uddbu95GnS0qtA7+Mt3FLegu3MByX2f1ii5qoYyCQ==" />
</appSettings>
</configuration>
Creating config file through IConfigInit
The following shows a simple console program that creates a config template file with encrypted client id and secret.
A simple Console program for creating a config file with credentials.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// See https://aka.ms/new-console-template for more information
using CommandLine;
using System.Runtime.CompilerServices;
using SwpTrmLib.Cloud;
Console.WriteLine("Create SwpTrmLib.dll.config");
SwpTrmLib.Cloud.IConfigInit? config;
if (args.Length == 0)
{
args = new string[] { "--help" };
}
var options = Parser.Default.ParseArguments<Options>(args);
if (options.Errors.Count() == 0)
{
if (options.Value.test)
{
Console.WriteLine("Config template for test environment.");
config = ConfigInit.Create4Test();
}
else
{
Console.WriteLine("Config template for production environment.");
config = ConfigInit.Create4Prod();
}
if (!string.IsNullOrEmpty(options.Value.ClientID))
{
config.SetClientId(options.Value.ClientID);
}
if (!string.IsNullOrEmpty(options.Value.Secret))
{
config.SetClientSecret(options.Value.Secret);
}
if (config != null) fixGetTokenUrls();
}
Console.WriteLine("Done!");
void fixGetTokenUrls()
{
string text = File.ReadAllText("SwpTrmLib.dll.config");
text = text.Replace("B2C_1_default", "B2C_1_terminal");
File.WriteAllText("SwpTrmLib.dll.config", text);
}
public class Options
{
[Option('t',"test", Required=false, HelpText ="Generates config file with url:s for test.")]
public bool test { get; set; }
[Option('p', "prod", Required = false, HelpText = "Generates config file with url:s for prod.")]
public bool prod { get; set; }
[Option("clientid",Separator='=', Required =false, HelpText ="Oauth2 client id")]
public string ClientID { get; set; }
[Option("secret", Separator = '=',Required = false, HelpText = "Oauth2 secret")]
public string Secret { get; set; }
}