How to Integrate ANAF SPV E-Invoicing with Java Spring Boot Using OAuth2 and JWT
Romanian tax authority ANAF requires businesses to submit B2B e-invoices through its SPV platform using OAuth2 authorization code flow with JWT access tokens, not simple API keys. Integration involves redirecting an operator to ANAF's login page, where they authenticate via a digital certificate, after which the backend exchanges a one-time code for short-lived JWT tokens that expire in roughly ten minutes. Developers must include the token_content_type=jwt parameter on both the authorization and token exchange requests, or ANAF returns a legacy token format. A Spring Boot implementation using AnafTokenManager handles token storage and refresh logic, with settings drawn from a database first and environment variables as a fallback to allow reconnection without redeployment. Key pitfalls include sparse documentation, Romanian-language error messages, and strict redirect URI matching where even a single character mismatch causes authentication to fail.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in