bunq / sdk_csharp

C# SDK for bunq API
MIT License
35 stars 22 forks source link

Implement psd2 #125

Closed kojoru closed 5 years ago

kojoru commented 5 years ago

This PR adds PSD2 support to the SDK. It was tested and the whole flow works again sandbox.

Usage is along the lines of:

var psd2ApiContext = ApiContext.CreateForPsd2(environmentType, certificate, certificateChain, 
    deviceDescription, permittedIps);
BunqContext.LoadApiContext(psd2ApiContext);
var allOauthClient = OauthClient.List();
if (!allOauthClient.Value.Any())
{
    OauthClient.Create("ACTIVE");
    allOauthClient = OauthClient.List();
}

var client = allOauthClient.Value.First();
Debug.Assert(client.Id != null, "client.Id != null");
if (OauthCallbackUrl.List(client.Id.Value).Value.All(ocu => ocu.Url != redirectUri))
{
    OauthCallbackUrl.Create(client.Id.Value, redirectUri);
}

Console.WriteLine(JsonConvert.SerializeObject(client));

This PR closes/fixes the following issues: