Provides functionality for onboarding new clients to your PowerOfficeGo integration using the OAuth2 onboarding flow.
$ dotnet add package PowerOfficeGoV2OnboardingThis project provides functionality for onboarding new clients to your PowerOfficeGo integration using the OAuth2 onboarding flow.
To use this onboarding flow you need to have your url whitelisted by the PowerOffice team, separately for the live environment and the demo environment.
Send an email to go-api@poweroffice.no indicating whether you need your url whitelisted for the demo environment or the live environment. The url you whitelist should be: <your_api_base_url>/PowerOfficeGoOnboarding/authenticate
It can be localhost for testing purposes.
In your Program.cs:
using PowerOfficeGoV2.Extensions;
using PowerOfficeGoV2Onboarding.Extensions;
...
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddPowerOfficeGoApi(options =>
{
// Use the PowerOfficeGo demo api (for demo clients). Default is false.
options.UseDemoApi = true;
});
builder.Services.AddPowerOfficeGoOnboarding();
...
public class YourService
{
private readonly IPowerOfficeGoV2OnboardingService _powerOfficeGoOnboardingService;
public YourService(IPowerOfficeGoV2OnboardingService powerOfficeGoOnboardingService)
{
_powerOfficeGoOnboardingService = powerOfficeGoOnboardingService;
}
public async Task YourMethodAsync()
{
var response = await powerOfficeGoOnboardingService.BeginOnbardingAsync(
"application_key",
"subscription_key",
"client_org_number",
// This base url is used for the onboarding controller included in this project.
"https://your-api.com",
// This can be either your api or your frontend, depending on your needs
"https://your-url.com/client-onboarding");
// Redirect your user to response.RedirectUri
}
}
When the onboarding session completes (succeeds or fails), the user will be redirected to the url you provided, https://your-url.com/client-onboarding in the above example.
If the onboarding failed, the errorMessage query parameter will be included.
For example: https://your-url.com/client-onboarding?errorMessage=IntegrationBlocked
If the onboarding succeeds, the following query parameters will be included: clientKeys, clientNames, clientOrganizationNumbers, userEmail.
Notice that all values except userEmail can be comma separated lists, in case multiple clients were onboarded.
For example (but url encoded): https://your-url.com/client-onboarding?clientKeys=f1ba4158-7bbc-4ecc-a68d-1a8ac42c5480,A34DA14A-9D3E-4736-9867-E3A23EE7EE7E&clientNames=ABC AS,XYZ AS&clientOrganizationNumbers=980386465,12345678&userEmail=jon.doe@company.no
If you need to pass additional information on redirect, you can do this by including query parameters in the redirect url.
For instance:
var response = await powerOfficeGoOnboardingService.BeginOnbardingAsync(
"application_key",
"subscription_key",
"client_org_number",
"https://your-api.com",
"https://your-url.com/client-onboarding?myIdentifier=123");The user will then be redirected to the following url when onboarding completes: https://your-url.com/client-onboarding?myIdentifier=123&clientKeys=...