Add Client Credentials Flow (Service Account) support to Authorizatio…#55
Merged
GGAlanSmithee merged 2 commits intomasterfrom Dec 2, 2025
Merged
Add Client Credentials Flow (Service Account) support to Authorizatio…#55GGAlanSmithee merged 2 commits intomasterfrom
GGAlanSmithee merged 2 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for Fortnox's Client Credentials Flow (Service Accounts), enabling server-to-server integrations without user-tied OAuth tokens. The implementation follows existing patterns in the codebase for OAuth flows, adding new methods to exchange credentials for service account tokens and extending the authorization URL generation to support service account activation.
- Added
GetServiceAccountTokenAsyncmethod that implements the Client Credentials Flow for obtaining access tokens - Extended
GetAuthorizationUrlwith an optionalaccountTypeparameter to enable service account creation during the OAuth flow - Introduced
ServiceAccountTokenmodel to represent the response from the Client Credentials Flow (containing access_token, token_type, and expires_in)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| Fortnox.NET/Services/AuthorizationService.cs | Added GetServiceAccountTokenAsync method and accountType parameter to GetAuthorizationUrl for service account support |
| Fortnox.NET/Models/Authorization/ServiceAccountToken.cs | New model representing service account token response with AccessToken, TokenType, and ExpiresIn properties |
| Fortnox.NET/Communication/FortnoxAPIClient.cs | Implemented internal GetServiceAccountTokenAsync method to handle HTTP communication for Client Credentials Flow; minor whitespace formatting fixes |
| Fortnox.NET/Fortnox.NET.csproj | Version bump from 3.4.0 to 3.5.0 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Client Credentials Flow (Service Account) support to AuthorizationService
Description
Adds support for Fortnox's Client Credentials Flow (Service Accounts), enabling server-to-server integrations without user-tied OAuth tokens.
Changes
GetServiceAccountTokenAsyncmethod toAuthorizationServiceandFortnoxAPIClientaccount_typeparameter toGetAuthorizationUrlfor service account activationServiceAccountTokenmodel withAccessToken,TokenType, andExpiresInpropertiesUsage
Notes
tenantIdcan be obtained via webhook (consent.createdevent) or from/3/companyinformation(DatabaseNumberfield)